This is the original HTML:
<td class="danish">newtext</td>
<td><?php audioButton("../../audio/lessons/01/oldtext","oldtext"); ?></td>
<td><?php audioButton("../../audio/lessons/01/slow/oldtext_slx","oldtext_slx","1"); ?></td>
I want to replace 'oldtext' with 'newtext' using the RegReplace package in Sublime Text 2.
This is what I have in reg_replace.sublime-settings
(no need to analyze the whole thing. The point is that it has a few (.*) in it):
{
"replacements": {
"audiobutton_rep": {
"find": "<td class=\"danish\">(.*)</td>\\n.*<td><\\?php audioButton\\(\"(.*)/.*\",\".*\"\\); \\?></td>\\n.*<td><\\?php audioButton\\(\"(.*)/.*\",\".*\",\"1\"\\);.*\\?></td>",
"replace": "<td class=\"danish\">$1</td>\n<td><?php audioButton(\"$2/$1\",\"$1\");?></td>\n<td><?php audioButton(\"$3/$1_slx\",\"$1_slx\",\"1\");?></td>",
"greedy": true,
"case": false
},
This is the command in default.sublime-commands
:
{
"caption": "Reg Replace: XXXXXXXXXXXXXXXX",
"command": "reg_replace",
"args": {"replacements": ["audiobutton_rep"] }
},
The capture groups don't work, so the output looks like this:
<td class="danish">$1</td>
<td><?php audioButton("$2/$1","$1");?></td>
<td><?php audioButton("$3/$1_slx","$1_slx","1");?></td>
It works perfectly when I run it on its own, but not here.