$month matches error


#1

Can anyone tell me why the month matches is coming up true? It is October (10) of course.


#2

It matches the 1 since this is looking only at whether $month contains the pattern. To require a match of the entire value, modify the expression a bit to match only at the start and end of the string: /^(1|2|3|4|11|12)$/

With that expression you will only get matches when the value is exactly 1, 2, 3, 4, 11, or 12.


#3

Love this forum and the minions! Correct answer. Thanks Ian! @ipaterson