/^(20)(?(1)(0[7-9]|[^0]\d)|(21)\d\d)$/ PHP: I am trying to get this conditional expression to match dates between 2007 and 2199. If i try 2007, or anything of the form 20_ _, it works, when i try any year of the form 21_ _, it does not work Could you help me with this? it would be greatly appreciated. Thanks for your attention
/^2(0|1)(0[7-9]|[1-9][0-9])$/ Although I don't really understand why you'd want to do it like this? Judging by the ^ and $, the string only contains the number anyway, in which case a simple greater than 2007 and less than 2199 would be much quicker.
I am validating a whole date from a form text box, just could not get the year part working. I wanted to learn something from that expression i posted, since it did not work. Thanks for your suggestion,, i really appreciate it.
Unfortunately the pattern you gave does not work, it does not validate 2101, and some others. I found one that does though: '/^2(00[7-9])|(0[1-9]\d)|(1\d\d)$/' PHP: Thanks again.