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.
^TN-(In|Te|Yo|Et)-[A-Z]{2}-[A-Z]{2}-\d{4}-\d{1,4}$
就像评论一样,如果你想提高你的正则表达能力,我推荐你Rubular,当你需要使用正则表达式时,这是一个简单实用的页面
TN-(In|Te|Yo|Et)-([A-Z]{2}-){2}(19[7-9][0-9]|200[0-9]|201[0-2])-[0-9]{1,4}
TN-((In)|(Te)|(Yo)|(Et))-[A-Z]{2}-[A-Z]{2}-\d{4}-\d{1,4}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.