locked
regular expressions RRS feed

  • Question

  •  regular expressions

    " 4/21/2003 :     On 4/21/2003 6:02:49 PM By DBROWN ::      ;   
 On 4/21/2003 7:04:41 PM By DBROWN :: 
  called on 4/19 ;  "

    from the above string

    can any one tell me the pattern to

    extract the date preceded by 'On ' and name preceded by 'By'

    Wednesday, November 8, 2006 7:39 AM

All replies

  • Regex r = new Regex(@"On\s+(?<MyDate>[\s\S]+)\s+By(?<MyName>[\s\S]+)",
            RegexOptions.Compiled);
                Console.WriteLine(r.Match(InString).Result("${MyDate}${MyName}"));

    Hope this Help
    Wednesday, November 8, 2006 11:25 AM