我在控制台应用程序中有代码
reg = new Regex(@"/[a-z0-9_\-\+]+@[a-z0-9\-]+\.([a-z]{2,3})(?:\.[a-z]{2})?/i");
string text = "wjeqklejqwek myEmail@hotmail.com a;lekqlwe anothermail@mail.ru";
parseTextByTagName("", text);
MatchCollection coll = reg.Matches(text);
}
当我调试它时它显示 coll 是空的你能告诉我我正在解决它大约一个小时的问题吗
试试这个
string strRegex = @"[A-Za-z0-9_\-\+]+@[A-Za-z0-9\-]+\.([A-Za-z]{2,3})(?:\.[a-z]{2})?";
Regex myRegex = new Regex(strRegex, RegexOptions.None);
string strTargetString = @"wjeqklejqwek myEmail@hotmail.com a;lekqlwe anothermail@mail.ru";
foreach (Match myMatch in myRegex.Matches(strTargetString))
{
if (myMatch.Success)
{
// Add your code here
}
}