62,041
社区成员
发帖
与我相关
我的任务
分享
string oldstring="最高:<span id="bfn_hi_600050.sh" class="color_red">6.32</span>最低:";
string newString="";//我想通过正则得到6.32
string oldstring="最高:<span id="span1">10000</span>最低:";
string newString="";//我想通过正则得到10000
string oldstring="最高:<span id="span1">10000</span>最低:";
string newString="";//我想通过正则得到10000
Match match = Regex.Match(oldstring, @"最高:<span[^>]+>(?<number>[^<]+)</span>最低:", RegexOptions.IgnoreCase);
while (match.Success)
{
newString += match.Groups["number"].Value + ",";//每项之间用逗号隔开
match = match.NextMatch();//批配下一项
}
string oldstring="最高:<span id="span1">10000</span>最低:";
string newString="";//我想通过正则得到10000
Match match = Regex.Match(oldstring, @"最高:<span[^>]+>(?<number>[^<]+)</span>最低:", RegexOptions.IgnoreCase);
if (match.Success)
{
newString=match.Groups["number"].Value;
}
string strText = @"最高:<span id=""bfn_hi_600050.sh"" class=""color_red"">6.32</span>最低:";
Regex _regex = new Regex(@".*最高.*>(?<max>.*)</span>最低:");
MatchCollection _matchCollection = _regex.Matches(strText);
foreach (Match objMatch in _matchCollection)
{
Console.WriteLine(objMatch.Groups["max"].Value);
}
@"(?i)(?<=最高:<span\b[^>]*>)[^<]+(?=</span>最低:)"