regex - What's the regular expression that matches a square bracket? (Part II) -


this continuation of previous thread because none of answers there produced intended result. getting super wierd behavior using regexes match dates. want match following dates:

[month-day] 

such as:

"[01-23]" // january 23rd valid date "[02-31]" // february 31st invalid date "[02-16]" // valid "[ 6-03]" // invalid format 

here regex:

regex = /\[^[0-1][1-9]\-[0-3][0-9]\]/ 

i tried put both single \ , double \ infront of brackets nothing seems working matching these dates. ideas?

thanks!

the problem regex placement of start-of-line anchor ^ after initial square bracket. cannot happen, regex never matches anything.

move anchor beginning of expression fix problem:

regex = /^\[[0-1][1-9]\-[0-3][0-9]\]/ 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -