C# Regular Expressions

Updated: 07 July 2023

A brief example

string pattern = @"\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\b";
Regex rg = new Regex(pattern);
string dates = "Tuesday 25th May & Monday 1st of Apr.";
MatchCollection matched_dates = rg.Matches(dates);

for (int count = 0; count < matched_dates.Count; count++)
Console.WriteLine(matched_dates[count].Value);

# May
# Apr

Leave a comment