- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 09:39 AM
Hello I'm working on creating a regular expression for a US phone number. The format needs to be +1 XXX-XXX-XXXX.
I found this post below which provided a Regex expression of ^\(?([0-9]{3})\)?[-]([0-9]{3})[-]([0-9]{4})$ but I'm having issues wit the leading 1.
Does anyone have any tips or assistance on how to complete this? This isn't my strong suit and my first time working on Regex expression so all help would be great!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 03:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 03:11 PM - edited 12-01-2023 03:13 PM
^\+1\s\d{3}[-]\d{3}[-]\d{4}$
or
^\+1\s?\(?([0-9]{3})\)?[-]([0-9]{3})[-]([0-9]{4})$

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 10:10 AM
Try below
^(\+1)?([0-9]{3})\)?[-]?([0-9]{3})[-]?([0-9]{4})$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 12:27 PM
this does not allow a space between the 1 and area code

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 09:04 AM
@KB30 try below
^(\+1)?(\s+)?([0-9]{3})\)?[-]?([0-9]{3})[-]?([0-9]{4})$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 07:29 AM
@Jaspal Singh I can submit with the space between the 1 and the area code but the rest of the format does not work at all for the number. I can submit numbers with no hyphens
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 09:29 AM
HI @KB30 ,
I trust you are doing great.
Here's a regular expression that matches the phone number format +1 XXX-XXX-XXXX:
^\+1\s?([0-9]{3})[-]([0-9]{3})[-]([0-9]{4})$
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi