javascript - Regular expression including wildcard character in search string -


i want regular expression string string can contain * , ? in it. should have @ least 3 alphanumeric character in it. so,

*abc* valid *ab*c valid *aaa? valid *aa  not valid **aaa not valid not valid regular expression 

this should it:

^[*?]?([0-9a-z][*?]?){3,}$ 

explanation:

  • ^ matches beginning of string
  • [*?]? matches optional * or ?
  • (...){3,} group must appear @ least 3 times
  • [0-9a-z][*?]? matches alphanumeric character followed optional * or ?
  • $ matches end of string

consecutive * , ? not matched.

update: forgot mention it, on mind: use i modifier make match case-insensitive (/.../i).


Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -