Possible Duplicate:
removing unwanted text
I want to remove extra text:
test is like that www.abc.com dsfkf ldsf <info@abc.com>
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 <info@abc.com>
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 mail@something.com some other mail test.simple@something.net text.";
Match m = Regex.Match(text, regex);
while (m.Success)
{
foundMails.Add(m.ToString());
m = m.NextMatch();
}
foundMails collection contains found emails