Regex仅匹配html元素的第一个匹配项

Regex仅匹配html元素的第一个匹配项,regex,xhtml,notepad++,Regex,Xhtml,Notepad++,是的,我知道,“不要用正则表达式解析HTML”。我正在用记事本++做这件事,这是一次性的,所以请耐心等待 我试图通过使用一些更高级的技术来简化一些HTML代码。值得注意的是,在我的文档中,我有“插入”或“标注”或任何你称之为“标注”的词,表示“注意”、“警告”和“技术”短句,以吸引读者对重要信息的注意: <div class="note"> <p><strong>Notes</strong>: This icon shows you som

是的,我知道,“不要用正则表达式解析HTML”。我正在用记事本++做这件事,这是一次性的,所以请耐心等待

我试图通过使用一些更高级的技术来简化一些HTML代码。值得注意的是,在我的文档中,我有“插入”或“标注”或任何你称之为“标注”的词,表示“注意”、“警告”和“技术”短句,以吸引读者对重要信息的注意:

<div class="note">
    <p><strong>Notes</strong>: This icon shows you something that complements 
     the information around it. Understanding notes is not critical but 
     may be helpful when using the product.</p>
</div>
<div class="warning">
    <p><strong>Warnings</strong>: This icon shows information that may 
     be critical when using the product. 
     It is important to pay attention to these warnings.</p>
</div>
<div class="technical">
    <p><strong>Technical</strong>: This icon shows technical information 
     that may require some technical knowledge to understand. </p>
</div>

注意事项:此图标向您显示补充内容
它周围的信息。理解笔记不是关键,而是关键
使用本产品时可能会有所帮助

警告:此图标显示可能会导致 使用本产品时,请务必谨慎。 重要的是要注意这些警告

技术:此图标显示技术信息 这可能需要一些技术知识才能理解

我想将此HTML简化为以下内容:

<div class="box note"><strong>Notes</strong>: This icon shows you something that complements 
     the information around it. Understanding notes is not critical but 
     may be helpful when using the product.</div>
<div class="box warning"><strong>Warnings</strong>: This icon shows information that may 
     be critical when using the product. 
     It is important to pay attention to these warnings.</div>
<div class="box technical"><strong>Technical</strong>: This icon shows technical information 
     that may require some technical knowledge to understand.</div>
注释:此图标显示一些补充信息
它周围的信息。理解笔记不是关键,而是关键
使用本产品时可能会有所帮助。
警告:此图标显示可能会导致
使用本产品时,请务必谨慎。
重要的是要注意这些警告。
技术:此图标显示技术信息
这可能需要一些技术知识才能理解。
我几乎有了从notepad++在我的项目中进行良好的全局搜索和替换所需的正则表达式,但它不会“只”拾取第一个div,而是拾取所有div-如果我的光标位于文件的开头,那么我单击“查找”时的“选择”基本上是从第一个
一直到最后一个


下面是我的表达式:
在匹配
属性时,您有一个贪婪的点量词-这就是导致您出现问题的邪恶家伙

使其非贪婪:


比较:vs

很好地保持了操作员的不情愿。我会尝试将此部分更改为:
class=“(.*[^”])”
class=“([^”]*)”
开始。我知道这是一个愚蠢的语法错误。谢谢你,亚历克斯!