.

email grabber in c#

code:

[TestFixture]
public class EmailGrabberTests
{
    [Test]
    public void Testx()
    {
        var text = @"sadf sdf at piet.c@gmail.cmo ens
and sno_w@wer.com";
        var emails = EmailGrabber.Grab(text);
        Assert.AreEqual("piet.c@gmail.cmo", emails[0]);
        Assert.AreEqual("sno_w@wer.com", emails[1]);
    }

}

public  class EmailGrabber
{
    /// <summary>
    /// grab emails from text
    /// </summary>
    /// <param name="text"></param>
    /// <returns></returns>
    public static string[] Grab(string text)
    {
        const string LocalLinkRegex =
@"(?<email>\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)";
        var R2 = new Regex(LocalLinkRegex, RegexOptions.IgnoreCase);
        var Matches2 = R2.Matches(text);

        var enumerable = new List<string>();
        foreach (Match m in Matches2)
        {
            enumerable.Add(m.Groups["email"].Value);
        }
        return enumerable.ToArray();
    }
}

What's your thoughts on this?

*

Protected by WP Anti Spam