Possible Duplicate:
removing unwanted text
I want to remove extra text:
test is like that www.abc.com dsfkf ldsf <[email protected]>
I want to get only the email text in C#
Possible Duplicate:
removing unwanted text
I want to remove extra text:
test is like that www.abc.com dsfkf ldsf <[email protected]>
I want to get only the email text in C#
Use
string textInBrackets = Regex.Match(yourText, "(?<=<)[^>]*(?=>)").ToString();
If you want to get all emails from text, you can try this:
List<string> foundMails = new List<string>();
string regex = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
string text = "some text [email protected] some other mail [email protected] text.";
Match m = Regex.Match(text, regex);
while (m.Success)
{
foundMails.Add(m.ToString());
m = m.NextMatch();
}
foundMails collection contains found emails
Check out this post's answers, it should have everything you need to get on track. http://stackoverflow.com/questions/1000747/validating-an-email-address-in-c