Regex.Replace - replacing substrings using System.Text.RegularExpressions.Regex
Posted on 2004-09-25
I have a date string like "Sep-20-2004" which I need to convert to "9/20/2004" using regular expressions. The source string can, of course, be any date, like "Jan-1-2004", Jul-04-2004" etc.
I know how to convert it using DateTime, String.Replace etc. I understand that there may be more efficient ways of doing this. I need regex based solution.
What I am looking for is something like
string olddateformat = "Sep-20-2004";
string pattern = @".....";
string replace= @"......";
string newdateformat = Regex.Replace(olddateformat, pattern, replace);