我在控制台应用程序中有代码
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);
}
Run Code Online (Sandbox Code Playgroud)
当我调试它时,它表明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
}
}
Run Code Online (Sandbox Code Playgroud)