I want a regular expression for a string
This string can contain * and ? in it. But should have at least 3 alphanumeric character in it.
So,
*abc* is valid
*ab*c is valid
*aaa? is valid
*aa is not valid
**aaa is not valid as it is not a valid regular expression
This should do it:
Explanation:
^matches the beginning of the string[*?]?matches an optional*or?(...){3,}the group must appear at least 3 times[0-9a-z][*?]?matches an alphanumeric character followed by an optional*or?$matches the end of the stringConsecutive
*and?are not matched.Update: Forgot to mention it, but it was on my mind: Use
imodifier to make the match case-insensitive (/.../i).