using System.Text.RegularExpressions;
content = Regex.Match(content, "相关搜索(?<val>[\\s\\S]*?)search", RegexOptions.IgnoreCase).Groups["val"].Value.Replace("\r","").Replace("\n","");
MatchCollection TitleMatch = Regex.Matches(content, ">(?<val>[\\u4e00-\\u9fa5|\\w]*?)</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
// System.Text.RegularExpressions.Group TitleMatch = Regex.Match(content, ">(?<val>[\\u4e00-\\u9fa5|\\w]*?)</a>", RegexOptions.IgnoreCase).Groups["val"];
textBox1.Text = TitleMatch[2].Groups["val"].Value;
//下面的是取得比较正确的一个
MatchCollection TitleMatch = Regex.Matches("2.5%-15.5%", @"[\d\.]+%", RegexOptions.IgnoreCase );
、、、、注意,这里就不用转意字符\了
return TitleMatch[0].ToString();
private string remax(string chars)
{
string temp = "";
MatchCollection TitleMatch2 = null;
// MatchCollection TitleMatch = Regex.Matches("2.5%-15.5%", @"[\d\.]+%", RegexOptions.IgnoreCase );
MatchCollection TitleMatch = Regex.Matches(chars, @"[\d\.]+%", RegexOptions.IgnoreCase);
if (TitleMatch.Count > 0)
temp = TitleMatch[TitleMatch.Count - 1].ToString();
else if (TitleMatch.Count == 0)
{
TitleMatch2 = Regex.Matches(chars, @"\d+元", RegexOptions.IgnoreCase);
if (TitleMatch2.Count > 0)
temp = TitleMatch2[TitleMatch2.Count - 1].ToString();
}
return temp;
}