I have a bunch of strings in the following format -
"- (username) on (date) in (country) for (department)"
Examples -
- user.001 on July 15, 2012 in Africa for Human Resources \r\n\t\t\tEdit
- someusername on January 01, 2012 in United States for HR \r\n\t\t\tEdit
- userid on August 15, 2012 in Asia for Whatever\r\n\t\t\tEdit
- 100100.user on May 21, 2002 in New England for ABC \r\n\t\t\tEdit
How do I extract username, date, country and department using regex and C#?
Thanks for the help!
Edit 1: I discovered that some of the input strings do not have department. It is optional. e.g. "- user.001 on July 15, 2012 in Africa\r\n\t\t\tEdit". How do I handle this?
string.substringwhich is very tedious.C# in a nutshellhas a very very good explanation onREGEX