我想使用正则表达式来查找两个标签之间的内容,如下所示:
<br />@ This is the content.</li>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我一直在使用:
<br />@(.*?)</li>
Run Code Online (Sandbox Code Playgroud)
内容有时包含<li>标签,这不是我想要的.所以现在我想修改我的搜索,例如match <br />@(.*?)</li>不包含<li> tag.
然后我尝试:<br />@([^<li>].*?)</li>,但这仍包括<li>在搜索中.
你能给我一点帮助吗?谢谢.(注意,我使用TextWrangler)
这个表达式将:
<br />和结尾的子串</li><li><br\s*\/>(@(?:(?!<li>).)*?)<\/li>

示范文本
实例:http://www.rubular.com/r/CIledJX54O
注意第一行的状况不好
<br />@ Don't <li>find me.</li>
<br />@ This is the content.</li>
<br />@ more desired content.</li>
Run Code Online (Sandbox Code Playgroud)
捕获组
[0] => Array
(
[0] => <br />@ This is the content.</li>
[1] => <br />@ more desired content.</li>
)
[1] => Array
(
[0] => @ This is the content.
[1] => @ more desired content.
)
Run Code Online (Sandbox Code Playgroud)