简体   繁体   English

搜索并替换正则表达式和崇高文本

[英]Search and replace with regex and sublime text

I need to find all of the instances of the following pattern: 我需要找到以下模式的所有实例:

<(h1|p) class="veronaText hidden" (.*?)>(Answer:|)</(h1|p)>

and replace it to add an ID and an extra class. 并替换它以添加ID和额外的类。 How can I replace it so that it keeps its current formatting and attributes (h1 or p, etc)? 如何更换它以保持其当前格式和属性(h1或p等)?

<(h1|p) class="veronaText hidden" (.*?)>(Answer:|)</(h1|p)>

becomes

<$1 id="newID" class="veronaText hidden newClass" $2>$3</$4>

each $n represents a submatch within the main match, in the order they appear. 每个$ n代表主匹配中的子匹配,按它们出现的顺序排列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM