Can you have multiple validation regrex formats?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 08:12 AM - edited 10-23-2024 08:33 AM
I want to include international numbers for the phone number field and allow if the number +1 is included. so the regrex I have now is ^\+?[1-9]\d{0,2}[-. ]?\(?\d{1,4}?\)?[-. ]?\d{1,4}[-. ]?\d{1,9}$
However some testers are using manually created user accounts to test and the profiles have numbers with spaces like (303) 748-9843. Am I able to include another format to include spaces or can i use one regrex that can account for spaces and non space telephone numbers? I'm not familiar with this feature and I've looked up a few and it doesn't specify having more than one or include both spaces and non spaces.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 06:04 AM
You can try this one:
(\+?( |-|\.)?\d{1,2}( |-|\.)?)?(\(?\d{3}\)?|\d{3})( |-|\.)?(\d{3}( |-|\.)?\d{4})
It will validate for all the scenarios below:
11234567890
123-456-7890
(123) 456-7890
1 (123) 456-7890
123 456 7890
1 123 456 7890
123.456.7890
1 123.456.7890
1.123.456.7890
+1 123.456.7890
+91 (123) 456-7890
+1-(800)-555-2468
1-234-567-8912
+22-432-359-3687
If you found my answer helpful or correct ✔️ in any way, please don't forget to mark it to help future readers! 👍
--
Kind regards,
Marcos Kassak
Solution Consultant 🎯