2 questions on RegEx

1) how do I code a RegEx to require 8 numeric digits, with the first digit 1 or greater?

2) What's the popular website where I can test Reg Ex'es online?

Thanks!
newbiewebSr. Software EngineerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Patrick MatthewsConnect With a Mentor Commented:
For #1:

[1-9]\d{7}

To test the whole string:

^[1-9]\d{7}$

For #2, I would use Expresso:

http://www.ultrapico.com/Expresso.htm
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks!
0
 
newbiewebSr. Software EngineerAuthor Commented:
The $ means the string must terminate there?
0
 
newbiewebSr. Software EngineerAuthor Commented:
Oddly, my "poor man's" version works but yours fails:

'^[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'

'^[1-9]\d{7}'

Any idea why?
0
 
Patrick MatthewsCommented:
Each language has its own implemntation of RegExp.  In some dialects $ terminates a string, but some others use a different character.  Also, some dialects use \d for any digit 0-9, but other dialects do not.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.