c# 正则表达式查找字符串

string detail = “something html”; //string detail = "hi,i am lucy"; //Regex reg = new Regex(@"[/s/S]*好评率:[/s/S]*<strong>(/d{0,5}[.]/d{0,5})%</strong>", RegexOptions.IgnoreCase); //数字 Regex reg = new Regex(@"[/s/S]*好评率:[/s/S]*<strong>(.*)%</strong>", RegexOptions.IgnoreCase); Match match = reg.Match(detail); string year = match.Groups[1].Value; MessageBox.Show(year);

说明:

1、一定要用分组();

2、match.Groups[0].Value是原字符串;

3、[/s/S]换行回车

4、ikmb

你可能感兴趣的:(html,正则表达式,String,C#,regex)