我有一大块 HTML。
有了这个:
~<div>(?:.*?)<a[\s]+[^>]*?href[\s]?=[\s"\']+(#_ftnref([0-9]+))["\']+.*?>(?:[^<]+|.*?)?</a>(.*?)</div>~si
我正在捕捉这个:
<div> </div><hr align="left" size="1" width="33%" /><div><p><a title="" href="#_ftnref1">[1]</a> This is not to suggest that there are only two possible arguments to be made in support of blah blah <em>blah</em>.</p></div>
但!我要这个:
<div><p><a title="" href="#_ftnref1">[1]</a> This is not to suggest that there are only two possible arguments to be made in support of blah blah <em>blah</em>.</p></div>
你能帮我吗?
PS: (?: )
与 相比( )
,用于避免捕获文本。我是故意这样做的,因为我希望返回的 $matches 数组对于本文中未提及的几个不同的正则表达式保持一致。