正则表达式中间的部分不会写?

huagou 2012-03-17 01:39:06
<br /><strong>Language: </strong>中间是我想要的东西</p></td></tr>

请问这个正则表达式怎么写?

其中:“中间是我想要的东西”这部分的字符串长度不确定,有可能是英文字母,数字和空格。
...全文
108 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dalmeeme 2012-03-17
  • 打赏
  • 举报
回复
		string s = @"<br /><strong>Language: </strong>中间是我想要的东西</p></td></tr>";
Match match = Regex.Match(s, @"(?is)<strong>.*?</strong>(.+?)</p></td>");
Response.Write(match.Groups[1].Value);

输出:
中间是我想要的东西
gzdiablo 2012-03-17
  • 打赏
  • 举报
回复
			Regex re = new Regex(@"<strong>Language:[\s\S]*?</strong>([\s\S]*?)</p>", RegexOptions.IgnoreCase);
MatchCollection matches = re.Matches(str);
foreach(Match match in matches)
{
Console.WriteLine(match.Groups[1].Value);
}

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧