I have an application where I need to parse a string to find all the e-mail addresses in a that string. I am not a regular espression guru by any means and not sure what the differnce is between some expressions. I have found 2 expressions that, apprently, will match all of the e-mail addresses in a string. I cannot get either to work in my C# application. Here are the expressions:
/\b([A-Z0-9._%-]+)@([A-Z0-9.-]+\.[A-Z]{2,4})\b/i
^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$
Here is an example string:
Adam
<mailto:[email protected]?subject=Your%20prospect%20Search%20-%20ID:
%2011111> Edwards - Prospect ID: 11111, Ph: (555) 555-5555
Al
<mailto:[email protected]?subject=Your%20prospect%20Search%20-%20
ID:%20222222> Grayson - Prospect ID: 222222, Ph:
Angie
Here is the code in c#:
var mailReg = new Regex(EmailMatch, RegexOptions.IgnoreCase | RegexOptions.Multiline);
var matches = mailReg.Matches(theString);