regex - Regular expression with 6 characters in ASP.NET -
i need regular expression in asp.net accept 6 characters
,
- at second position should accept
underscore (_)
and - at third position should accept maybe
underscore (_)
orhash (#)
and - at fourth position should accept
hash (#)
.
note: in regex user can enter: number
, alphabets
or star (*)
@ position instead of above mentioned positions.
can 1 me out on this?
like:
- a__cde
- ab##cd
- a_#cde
- ******
- abcdef
- 123456
try following expression:
(?i)^(?=^(?:[a-z0-9*]*(?:#{1,2}|_{1,2})[a-z0-9*]*|[a-z0-9*]*)$).{6}$
will match:
a__cde
ab##cd
******
abcdef
123456
won't match:
a_#cde
a_##aa
a__#bc
_##*
Comments
Post a Comment