help with regex needed
Posted
by user268375
on Stack Overflow
See other posts from Stack Overflow
or by user268375
Published on 2010-06-09T13:18:32Z
Indexed on
2010/06/09
13:22 UTC
Read the original article
Hit count: 184
regex
I need a regular expression with the following needs:
the string is alphanumeric and have exactly 6 characters in the first half followed by hyphen(optional) followed by optional 4 characters:(cannot have more than 4 characters in the second half)
so any of the following is valid
11111A
111111-1
111111-yy
yyyyy-989
yyyyyy-9090
i thought this expression /[a-zA-Z0-9]([-])?[a-zA-Z0-9]{5,10}$/;
should work but i m unable to get it working correctly.
Any help will be appreciated,
© Stack Overflow or respective owner