Monday, March 18, 2013

Regex remove Day Name and Date Suffix

In a situation where i want to format this date value from (Tuesday 19th March 2013) to (19 March 2013). I made a regular expression by applying look behind approach and ends with behavior in strings. Here's the expression:
Code:
indicatorDate = Regex.Replace(indicatorDate, @"(\b[A-Za-z]*day\b)|((?<=[0-9])[a-zA-z]{2})", string.Empty, RegexOptions.IgnoreCase);
:)

0 comments:

Post a Comment