Regular Expression Help

E

elliott

I am still new to using Regular Expression and I trying to validate a
string. The string must be 3-16 letters or numbers and it must start
with a letter.

Here's what I have; but it doesn't work...

\w[a-zA-Z][_a-zA-Z0-9-]{2-15}\w

Thanks
 
M

Marc Gravell

Well, {2-15} should be {2,15}

What do you mean by \w? This means alpha-numerics... do you mean word
boundary? that is \b
If you mean the entire string (i.e. no unmatched chars) then use ^
(start) and $ (end)

e.g.

^[a-zA-Z][-_a-zA-Z0-9]{2,15]$
\b[a-zA-Z][-_a-zA-Z0-9]{2,15]\b
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top