Parsing this kind of string into DateTime - "Friday 22nd March 2013" (C#) -


I found a large part of the text like this:

.... Recommend that there is the ability to declare a day on Friday, March 22, 2013 .....

I will have to find the dated time (Friday 22nd March 2013) and then pars Have to do. I can find it and get almost everything to get datetime I can use Trips, but gradual suffixes (St, ND, RD, th) are throwing me.

When I am trying to format the format string before calling TryParse method Can I use any wildcard characters in mind with those suffixes? Or any other suggestions?

Thank you!

Regarding changing unwanted characters using a regex ?

The following regex should work as an example: "(? & Lt; = \ d) [az] {2}" .

Example code

  string date = "Friday 22 March 2013"; Var r = New Regex (@ "(? & Lt; = \ d) [a-z] {2}"); String result = R. Change (date, ""); Console.light line (datetime purse (result, culture, infographic, invertary culture));   

Output:

  22/03/2013 00:00:00   

It should take care of most of the cases, but be sure to check it properly.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -