Reputation: 1
I need a regular expression in ASP.NET that accept 6 characters
and
underscore (_)
andunderscore (_)
or hash (#)
andhash (#)
.Note: In regex user can only enter: Number
, Alphabets
or Star (*)
at any position instead of above mentioned positions.
Can any one help me out on this?
Like:
Upvotes: 0
Views: 52
Reputation: 1374
Try the 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
_##*
Upvotes: 1