I need to enforce a format for a field "2011-12 whatever else after"
The h开发者_如何学编程yphen needs to be included between the digits, and no spaces until after the second digit in the year. I think the hyphen is throwing this off. I've played with Expresso but to no avail.
\d{4}-0[1-9]|1[0-2].*
What's wrong with this?
Try ^\d{4}-(1[0-2]|0[1-9])\s
If you don't need the trailing space remove \s
.
This matches:
Sequence: match all of the following in order BeginOfLine Repeat Digit 4 times - CapturingGroup GroupNumber:1 OR: match either of the following Sequence: match all of the following in order 1 AnyCharIn[ 0 to 2] Sequence: match all of the following in order 0 AnyCharIn[ 1 to 9] WhiteSpaceCharacter
Unless I am misunderstanding the requirements, this should work fine:
^2011-12.*
精彩评论