.

C# Regular Expression links

Here are some links for c# regular expressions:
http://oreilly.com/windows/archive/csharp-regular-expressions.html

http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet

and a good c# regular expression tester:
TESTER

http://www.regexr.com/

simple c# regular expression example:

const string LocalLinkRegex = 
 @"href=""\/livechess\/game\.html\?id\=(?<GameId>[0-9]*)""";
var R2 = new Regex(LocalLinkRegex, RegexOptions.ExplicitCapture);
var Matches2 = R2.Matches(result);

string href;

 string FirstGameIdValue = Matches2[0].Groups["GameId"].Value;

/*
this will find:  /livechess/game.html?id=123456789
and return: 123456789  (which is token: GameId)
*/

or simply:

string title = Regex.Match(source,
    @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>",
    RegexOptions.IgnoreCase).Groups["Title"].Value;


Email regex:

\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

as per

http://www.regular-expressions.info/email.html

 

 

What's your thoughts on this?

*

Protected by WP Anti Spam