【发布时间】:2011-06-28 21:21:25
【问题描述】:
我有一种感觉,我真的在这里遗漏了一些明显的东西,但我正在寻找一个正则表达式,它可以匹配粗体标签的内容以及标签前后的单词。
所以:
"start this string <b>is the text</b> we need end"
会匹配到
"string <b>is the text</b> we"
我可以使用<b\s*>(.*?|[^>\s]+)<\/b\s*> 访问标签及其内容,但我似乎无法确定前导词和尾随词。
任何帮助将不胜感激。
【问题讨论】:
-
您想要一个正则表达式从
start this string <b>is the text</b> we need end获取例如string <b>is the text</b> we? -
我有点困惑为什么
.*?|[^>\s]+在中间。它比普通的.*?买了什么?