- 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-30-2023 11:50 AM
Hello @Amit Gujarathi
I tried your expression and I was able to submit with the no space between the +1and the area code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 02:05 PM
@Amit Gujarathi I tested your expression. I'm still able to submit with no space between the +1 and the area code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 02:37 PM
this might work
^1\s\d{3}-\d{3}-\d{4}$
- 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})$