Format a cellphone number with no special characters or spaces

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?

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?

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?

The plot thickens :slight_smile:

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?

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

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

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.

Screen Shot 2022-04-02 at 7.23.15 PM

To check if the number is “valid”, you can use the Check Text Matches plugin. This will return a true/false result, so you can use that to hide/show warnings, prevent form submission, etc.

To strip out the unwanted characters at the start, use the Extract Matching Text plugin.

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

5 Likes

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

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!

1 Like

You’re the God of regex here.

2 Likes

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