Can somebody interpret this Regular Expression?

  • Thread starter Thread starter Colin Young
  • Start date Start date
C

Colin Young

I can't figure out what strings would match this:

^[\w][a-zA-Z'-]{1,128}$

Thanks

Colin
 
Should have waited a couple minutes... It only allows word characters plus
single quotes and dashes, but no spaces. Any odd choice for a field that is
looking for a company name.

It's not the best example. Later on the same page there is a comment box
that doesn't allow "special" characters (you know, special characters like
periods and commas, and, oddly enough given the first example, single
quotes).

Colin

P.S. It's from the sign-up page for the 1-year MapPoint webservices
subscription for MSDN universal subscribers in case anyone is interested.
 
^ = beginning of string/line depending on Multiline option
[\w] = a single letter, digit, or underscore character
[a-zA-Z'-]{1,128} = at least 1, but not more than 128 letters,
single-quotes, or dashes
$ = end of string/line depending on Multiline option


Brian Davis
http://www.knowdotnet.com
 
I managed to figure that much out on my own. What I wasn't sure about was
whether a [\w] considered the space after a word or not. Once I decided it
did not, I was able to determine that basically the reason my entry was
invalid was because I had put spaces between my words.

As you can see from the reply to myself I should have done a few more
minutes of testing before posting...

Colin

Brian Davis said:
^ = beginning of string/line depending on Multiline option
[\w] = a single letter, digit, or underscore character
[a-zA-Z'-]{1,128} = at least 1, but not more than 128 letters,
single-quotes, or dashes
$ = end of string/line depending on Multiline option


Brian Davis
http://www.knowdotnet.com



Colin Young said:
I can't figure out what strings would match this:

^[\w][a-zA-Z'-]{1,128}$

Thanks

Colin
 
Back
Top