Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. How can I replace it so that it keeps its current formatting and attributes (h1 or p, etc)?

like image 508
Mild Fuzz Avatar asked Jul 12 '12 11:07

Mild Fuzz


1 Answers

<(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.

like image 143
Mild Fuzz Avatar answered Sep 24 '22 07:09

Mild Fuzz