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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -