Solved

Regular Expression- Range (telephone)

Posted on 2016-10-19
4
26 Views
Last Modified: 2016-10-19
Hi,

I need a regular expression code that identifies number between 8003966101 and 8003966150. Can someone help me with this?

Thanks.
0
Comment
Question by:ezzadin
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:Terry Woods
ID: 41851132
Pattern:
/80039661(0[1-9]|[1-4]\d|50)/

Open in new window


Depending on the language, the \ character may need escaping, and the pattern delimiters / may or may not need to be there.
0
 

Author Comment

by:ezzadin
ID: 41851185
Hi Terry,

Thanks. I tested the Regex using regexr.com and I'm only getting one match though.
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 41851308
Can you save your test data there and provide a link? The "g" pattern modifier would normally cause multiple occurrences to be matched, ie
/80039661(0[1-9]|[1-4]\d|50)/g

Open in new window

but it looks like the tool at your given link may use that pattern modifier by default. It seems to work for me:
http://regexr.com/3efmc
0
 

Author Comment

by:ezzadin
ID: 41851311
I see. This is working great. Thanks.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fixing some Issues with regex again 9 22
Regex Email Address 7 36
regex101 site usage 5 296
Best way to loop  through regex matches 5 54
by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now