Reputation:
RegEx has always been my Achilles' heel. I am writing web app, where user will input his identifier. I'm using RegexValidator
to validate this input.
The identifier should be something like this:
TN-In-PL-KW-2012-1234
And this is how the identifier is built:
TN
In
, Te
, Yo
or Et
Please help me writing RegEx to match this identifier.
Upvotes: 7
Views: 16720
Reputation: 3713
^TN-(In|Te|Yo|Et)-[A-Z]{2}-[A-Z]{2}-\d{4}-\d{1,4}$
Just as a comment, I recommend you Rubular if you want to improve your regex skills, it's a simple and practical page to have in mind when you need to work with regex
Upvotes: 7
Reputation: 10250
TN-(In|Te|Yo|Et)-([A-Z]{2}-){2}(19[7-9][0-9]|200[0-9]|201[0-2])-[0-9]{1,4}
Upvotes: 2