0
4

2 回答 2

0

I posted this question to Twitter and got a response back that worked for me.

(?s)^.*<b>(.*?)</b>.*

Replace with $1 and have G flag checked.

This solution did everything I needed. I had additional data that I had already excluded in my example that became unnecessary with this regex.

于 2012-05-26T00:04:15.193 回答
0

假设 html 不包含引号等,这应该符合您的需求。请注意,+将意味着空<b>标签被忽略。此外,html 并不是真正可以通过正则表达式传递的,因此这仅适用于基本标签。即使标签具有 ID 或类属性,它也应该可以工作,但绝对有办法打破这个正则表达式。

/<b[^>]*>([^<]+)<\/b>/
于 2012-05-25T16:29:53.597 回答