C# Regular Expressions - Get Second Number, not First

前端 未结 4 2028

I have the following HTML code:

106.2%  

Which I get the number through two phases:

R         


        
4条回答
  •  青春惊慌失措
    2020-12-22 08:03

    string html = @"106.4%
    106.2% ";
    string patten = @".*(?<=>)(.+?)(?=";
    foreach (Match match in Regex.Matches(html, patten))
    {
        Console.WriteLine(match.Groups[1].Value);
    }
    

    I have changed the regex as your wish, The output is

    106.4%
    106.2%
    

提交回复
热议问题