string sourceString = @"asdf< href=""ss.exe"" asdf";
string pattern = @"(href=""[^""]*"")";
System.Text.RegularExpressions.MatchCollection results = Regex.Matches(sourceString,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase);
foreach(Match result in results)
{
WL(result.Groups[1].Value);//输出
}
string pattern = @"(href=""[^""]*"")";
System.Text.RegularExpressions.MatchCollection results = Regex.Matches(sourceString,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase);
foreach(Match result in results)
{
WL(result.Groups[1].Value);//输出
}
string yourStr = ............;
Match m = Regex.Match(yourStr, @"href=(['""]?)[^""\s>]*\1", RegexOptions.IgnoreCase);
if(m.Success)
{
MessageBox.Show(m.Value);
}同时取多个的
string yourStr = .............;
MatchCollection mc = Regex.Matches(yourStr, @"href=(['""]?)[^""\s>]*\1", RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
richTextBox2.Text += m.Value + "\n";
}
-----------------------------------------------
msn:[email protected]