I'm creating a site usi开发者_如何学JAVAng asp.net and C# and i just need to know some regex to validate/highlight my 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.
[A-Z]{3}
\d{4}
For 1, you could also use (JAN|FEB|MAR|APR|...)
(you get the idea). Also, if you wanted to match all Unicode letters, you could swap [A-Z]
with \pL
.
If you didn't want these matched midstring, add a word boundary (\b
) on each side.
The regex part is already answered by @alex (+1), here is the information about regexes.
Sites where you can test your regexes online (very helpful!)
- regexstorm.net/tester
- refiddle.com/
- gskinner.com/RegExr/
Online resources on regex.
- .NET Framework Regular Expressions
- www.regular-expressions.info/ (Very helpful site about all regex flavors)
- Perlretut (About Perl regex, but anyway helpful)
精彩评论