Phone number regular expression for validation

Can I use Advanced / Pattern in application studio to force a phone number to be in the correct format?

I’m trying to use something like:

^(+\d{1,2}\s)?(?\d{3})?[\s.-]\d{3}[\s.-]\d{4}$

I’ve looked thru the documentation but can’t tell what type of pattern it is expecting in advanced / pattern. Has anyone done this before?

Sure, but that RegEx string had some issues–not sure if some backslashes got formatted out or not.
This works:

^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$

Pass
image

Fail
image

It won’t allow me to enter any of those characters into the pattern. Am I missing something or is it my version 2024.1?

Ah, yeah–it was fixed in 2024.2 I believe.

Well then, I guess it will need to be a function with custom code. sigh
Thank you :slight_smile:

1 Like