Answers.Body: <p>For what it's worth, you can strip out all non-numerics with this something like this:</p>
  
  <pre><code>{{ globalPhoneNumber.phoneNumber|replace('/[^0-9]/', '') }}
  </code></pre>
  
  <p>Or, as part of a tel: anchor:</p>
  
  <pre><code>&lt;a href="tel:{{ globalPhoneNumber.phoneNumber|replace('/[^0-9]/', '') }}"&gt;{{ globalPhoneNumber.phoneNumber }}&lt;/a&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-26T19:27:18.650Z
Answers.LastActivityDate: 2016-05-26T19:27:18.650Z
Answers.UserDisplayName: Nick Benson
Answers.Body: <p>I haven't tried this but I think that you can use the twig <a href="http://twig.sensiolabs.org/doc/filters/replace.html" rel="nofollow">replace</a> function. Something like:</p>
  
  <pre><code>{{ global.phone|replace({"(":"", ")":"", "-":"", " ":""}) }}
  </code></pre>
  
  <p><strong>Update</strong> In your case, since the prefix (1-) is required, and "-" are allowable, the replace string for "(555) 555-5555" would be:</p>
  
  <pre><code>{{ global.phone|replace({"(" : "1-", ") " : "-"}) }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-12T16:45:22.057Z
Answers.Text: Works great, however got an error with double pipe. Left one in code and it works no problem. Thank you!
Answers.UserDisplayName: frshjb373
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-12T16:45:56.810Z
Answers.Text: I fixed that. Sorry about that.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-12T16:47:02.570Z
Answers.Text: I'm glad it works. Which reminds me... I need to do that for a project I'm working on. So thanks! ;)
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-12T16:52:46.123Z
Answers.Text: fyi... i think that the phone number needs to include the prefix (1-) and dashes are allowable (i.e. 1-555-555-5555). So you may need to prefix that number as well.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-12T17:04:59.177Z
Answers.Text: I'll use the latter, but looking at documentation and recommendations around web, not seeing a clear rule to use (1-) prefix or not. Same goes for including dashes or not. I've always done only numbers disregarding prefix and that's always worked for me.
Answers.UserDisplayName: frshjb373
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-12T19:20:00.350Z
Answers.Text: Check out [this apple dev page](https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html). Looks like "+1" is the preferred prefix. The hyphens are completely optional.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-12T16:43:21.410Z
Answers.LastActivityDate: 2014-11-12T16:57:52.410Z
Answers.LastEditDate: 2014-11-12T16:57:52.410Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I am using a phone number in a global variable called <code>{{ global.phone }}</code> with the format "(555) 555-5555". I'd like to use that same variable/string and remove spaces, dash, and parenthesis to use for the href tel link. I've tried a few different things from Twig and Craft documentation, but nothing is working. Here's what I have right now.</p>
  
  <pre><code>&lt;p&gt;Ph: &lt;a href="tel:{{ global.phone|trim(' ') }}"&gt;{{ global.phone }}&lt;/a&gt;&lt;br/&gt;
  </code></pre>
  
  <p>Is this possible to do? If so any advise how to accomplish this?</p>
  
Tags: <templating><variable><string><globals>
Title: Remove white space and parenthsis from global from entry variable
ThreadText: # Remove white space and parenthsis from global from entry variable
  
  (Asked by: username_0 on 2014-11-12)
  
  I am using a phone number in a global variable called `{{ global.phone }}` with the format "(555) 555-5555". I'd like to use that same variable/string and remove spaces, dash, and parenthesis to use for the href tel link. I've tried a few different things from Twig and Craft documentation, but nothing is working. Here's what I have right now.
  
  ```
  <p>Ph: <a href="tel:{{ global.phone|trim(' ') }}">{{ global.phone }}</a><br/>
  
  ```
  
  Is this possible to do? If so any advise how to accomplish this?
  
  **Tags:** templating, variable, string, globals
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-05-26. Score: 4
  
  For what it's worth, you can strip out all non-numerics with this something like this:
  
  ```
  {{ globalPhoneNumber.phoneNumber|replace('/[^0-9]/', '') }}
  
  ```
  
  Or, as part of a tel: anchor:
  
  ```
  <a href="tel:{{ globalPhoneNumber.phoneNumber|replace('/[^0-9]/', '') }}">{{ globalPhoneNumber.phoneNumber }}</a>
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2014-11-12. Score: 4
  
  I haven't tried this but I think that you can use the twig [replace](http://twig.sensiolabs.org/doc/filters/replace.html) function. Something like:
  
  ```
  {{ global.phone|replace({"(":"", ")":"", "-":"", " ":""}) }}
  
  ```
  
  **Update** In your case, since the prefix (1-) is required, and "-" are allowable, the replace string for "(555) 555-5555" would be:
  
  ```
  {{ global.phone|replace({"(" : "1-", ") " : "-"}) }}
  
  ```
  
  > **Comments:**
  > **username_0**: Works great, however got an error with double pipe. Left one in code and it works no problem. Thank you!  
  > **username_2**: I fixed that. Sorry about that.  
  > **username_2**: I'm glad it works. Which reminds me... I need to do that for a project I'm working on. So thanks! ;)  
  > **username_2**: fyi... i think that the phone number needs to include the prefix (1-) and dashes are allowable (i.e. 1-555-555-5555). So you may need to prefix that number as well.  
  > **username_0**: I'll use the latter, but looking at documentation and recommendations around web, not seeing a clear rule to use (1-) prefix or not. Same goes for including dashes or not. I've always done only numbers disregarding prefix and that's always worked for me.  
  > **username_2**: Check out [this apple dev page](https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html). Looks like "+1" is the preferred prefix. The hyphens are completely optional.  
  
  ---
  
  