Regex in C#

Recent had to ramp up on my regex skills. i was using C#,  so decided to explore the Regex libs in C#

Some use cases.

  • Finding matches.
    • Lets say I want to extract all the numbers present in a string.
    • I identify the proper regex to use. So in this case “\d+”
    • Use Regex.matches. e.g.
var digitsGroups = Regex.Matches(username, @"\d+", RegexOptions.IgnoreCase);

 

Code.

 

Also, check this out : http://www.ultrapico.com/Expresso.htm

References.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s