I want to extract date from the string through regex.
String : log-bb-2014-02-12-12-06-13-diag
How to do it?
Here something to start:
string s = "log-bb-2014-02-12-12-06-13-diag"; Regex r = new Regex(@"d{4}-d{2}-d{2}-d{2}-d{2}-d{2}"); Match m = r.Match(s); if(m.Success) { DateTime dt = DateTime.ParseExact(m.Value, "yyyy-MM-dd-hh-mm-ss", CultureInfo.InvariantCulture); }
1.4m articles
1.4m replys
5 comments
57.0k users