简体   繁体   English

需要几个RegEx的帮助

[英]need help with a couple of RegEx

I'm creating a site using asp.net and C# and i just need to know some regex to validate/highlight my gridview. 我正在使用asp.net和C#创建一个站点,我只需要知道一些正则表达式来验证/突出我的gridview。

I need to highlight these cells in their own columns: 我需要在他们自己的列中突出显示这些单元格:

1- APR, MAR, etc. (three letters exactly)
2- 2011, 2012, etc.  (year)
3- blank cell in gridview

Some links/tutorials on basic regex would also help me. 关于基本正则表达式的一些链接/教程也会对我有所帮助。

  1. [AZ]{3}
  2. \\d{4}

For 1, you could also use (JAN|FEB|MAR|APR|...) (you get the idea). 1,你也可以使用(JAN|FEB|MAR|APR|...) (你明白了)。 Also, if you wanted to match all Unicode letters, you could swap [AZ] with \\pL . 此外,如果要匹配所有Unicode字母,可以将[AZ]\\pL交换。

If you didn't want these matched midstring, add a word boundary ( \\b ) on each side. 如果您不想要这些匹配的中间串,请在每一侧添加单词边界( \\b )。

The regex part is already answered by @alex (+1), here is the information about regexes. 正则表达式部分已由@alex(+1)回答,这是有关正则表达式的信息。

Sites where you can test your regexes online (very helpful!) 您可以在线测试正则表达式的网站(非常有用!)

Online resources on regex. 正则表达式的在线资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM