I have used regex(.,'^[0-8]{9}$') to restrict phone number to a must 9 digits under constraint

One more issue I have used regex(.,‘[1]{9}$’) to restrict phone number to a must 9 digits under constraint. However when I enter a digit like 617839071 which is 9 digits it refuses and instead display constraint message. What could be the problem? I want the digits to be any number between 1 and 9


  1. 0-8 ↩︎

When in doubt, “google it”… :wink:

Have a look at this and come back in you still have questions (it has an example of a phone regex): Restricting Text Responses With Regular Expressions — KoboToolbox documentation

BTW, the correct syntax for writing regex’s is rather arcane, so I almost always test them out with dedicated regex tools before deploying them in a form. I use this one a lot; https://regex101.com/

2 Likes

@LastyJakom, this post discussed previously could also solve your issue: