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); }
2.1m questions
2.1m answers
60 comments
57.0k users