# Format a cellphone number with no special characters or spaces

**URL:** <https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341>\
**Category:** Ask for Help\
**Created:** [April 2, 2022, 9:45am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341 "2022-04-02T09:45:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ToOFa\_Apps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/toofa_apps/32/36816_2.png) [@ToOFa\_Apps](https://community.glideapps.com/u/ToOFa_Apps)\
**Post date:** [April 2, 2022, 9:45am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/1 "2022-04-02T09:45:05Z")

</div>

I need to format a cellphone number. There must be only ten numbers/digits from the right, with no other characters or spaces.  
Any ideas?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [April 2, 2022, 10:29am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/2 "2022-04-02T10:29:10Z")

</div>

Just to be clear:

- you have a series of existing numbers that you want to reformat to a maximum of 10 digits, or
- you want to validate new numbers to be 10 digits, or
- both?

---

<div class="post-metadata">

**Author:** ![ToOFa\_Apps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/toofa_apps/32/36816_2.png) [@ToOFa\_Apps](https://community.glideapps.com/u/ToOFa_Apps)\
**Post date:** [April 2, 2022, 10:32am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/3 "2022-04-02T10:32:27Z")

</div>

Either option, preferably validate.  
If they enter +2773 678 22341 i need this 7367822341  
And if they add in text or characters like :’",\>?/ etc etc - to take it out of the result or even dissallow it from being entered?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [April 2, 2022, 10:40am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/4 "2022-04-02T10:40:36Z")

</div>

The plot thickens 🙂

So you want to automatically detect and strip out IDD prefixes?  
For all countries? Or are you assuming that all of your users will have South African numbers?

---

<div class="post-metadata">

**Author:** ![ToOFa\_Apps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/toofa_apps/32/36816_2.png) [@ToOFa\_Apps](https://community.glideapps.com/u/ToOFa_Apps)\
**Post date:** [April 2, 2022, 10:42am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/5 "2022-04-02T10:42:40Z")

</div>

just south african numbers, so i basically need the last 9 digits (sorry not 10) but without any other characters or spaces

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [April 2, 2022, 10:47am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/6 "2022-04-02T10:47:01Z")

</div>

> <https://stackoverflow.com/questions/4058001/validate-south-africa-cell-phone-number>

You could probably modify the regex given there. I don’t have time now, but I could have a fiddle later.

---

<div class="post-metadata">

**Author:** ![ToOFa\_Apps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/toofa_apps/32/36816_2.png) [@ToOFa\_Apps](https://community.glideapps.com/u/ToOFa_Apps)\
**Post date:** [April 2, 2022, 10:49am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/7 "2022-04-02T10:49:46Z")

</div>

Oh, sorry i forgot to mention that i need to do this only in a Glide Table, i know how to do it in google sheets, but this app i’m doing now is fully glide table only.  
Thanks for the link and the help, if you have a table only - solution i’d appreciate that.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [April 2, 2022, 11:29am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/8 "2022-04-02T11:29:53Z")

</div>

![Screen Shot 2022-04-02 at 7.23.15 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/4/1498480f036c9e5e8ba38468ac47fcb1393b5238.png)

To check if the number is “valid”, you can use the [Check Text Matches](https://www.glideapps.com/plugins/regex-matchany) plugin. This will return a true/false result, so you can use that to hide/show warnings, prevent form submission, etc.

 ![Screen Shot 2022-04-02 at 7.23.29 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/4/54254428ee60078df42d29256893b6d5c324b9be.png)

To strip out the unwanted characters at the start, use the [Extract Matching Text](https://www.glideapps.com/plugins/regex) plugin.

 ![Screen Shot 2022-04-02 at 7.23.43 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/2/22d1dc6dc0311bcd941a2c072d7185903b415d60.png)

The same regex is used in both: `^(?:\+27|0)?([6-8][0-9]{8})$`

---

<div class="post-metadata">

**Author:** ![ToOFa\_Apps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/toofa_apps/32/36816_2.png) [@ToOFa\_Apps](https://community.glideapps.com/u/ToOFa_Apps)\
**Post date:** [April 2, 2022, 11:35am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/9 "2022-04-02T11:35:56Z")

</div>

Okay great, thanks for that. I’ll try that right now. Exactly what i need.🤙

---

<div class="post-metadata">

**Author:** ![OVRV](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ovrv/32/41117_2.png) [@OVRV](https://community.glideapps.com/u/OVRV)\
**Post date:** [April 2, 2022, 1:50pm UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/10 "2022-04-02T13:50:43Z")

</div>

That is awesome Darren! I’m a complete newbie here, lol, but this is a definite bookmark.  
I’ve always become frustrated creating validations in php for webpage forms so with my steep learning curve in the app world your post is more than appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 3, 2022, 12:02am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/11 "2022-04-03T00:02:00Z")

</div>

You’re the God of regex here.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [April 4, 2022, 12:02am UTC](https://community.glideapps.com/t/format-a-cellphone-number-with-no-special-characters-or-spaces/40341/12 "2022-04-04T00:02:22Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
