And*_*c ॐ 2 regex html-parsing
我正在尝试从xhtml文档中检索其内容的特定标记,但它匹配错误的结束标记.
在以下内容中:
<cache_namespace name="content">
<content_block id="15">
some content here
<cache_namespace name="user">
<content_block id="welcome">
Welcome Apikot!
</content_block>
</cache_namespace>
</content_block>
</cache_namespace>
Run Code Online (Sandbox Code Playgroud)
id ="welcome"的content_block结束标记实际上被匹配为第一个打开的content_block标记的结束标记.
我正在使用的正则表达式是:
/<content_block id="(.*)">([\w\W]*?)<\/content_block>/i
Run Code Online (Sandbox Code Playgroud)
关于我失败的地方的任何指示?