Sublime Forum

Regex find between tags

#1

The jQuery snippets are incorrect in the latest version of Sublime. The $ are not escaped and need to be.

For example:

<snippet>
	<content><![CDATA[\$(${1/(.+)/(?1:':)/}${1:string/element/array/function/jQuery object/string, context}${1/(.+)/(?1:':)/})$0]]></content>
	<tabTrigger>$</tabTrigger>
	<description>$('select DOM Element')</description>
</snippet>

I figured out that I could search for something like this with regex turned on

^\\](\$)

to replace all non-escaped dollar signs, however, I need to limit it to ONLY non-escaped dollar signs inside the tags.

I can’t seem to get this to work. Any thoughts?

0 Likes

#2

you could maybe try something like this

((?=<content)(?:.*))(^\\])\$((?:.*)(?<=</content>))

and replace with

$1$2\\\$$3

You would have to run it multiple times though since regex is not really recursive: it can only find a finite number of matches, so you would have to run it until all you don’t find any more.

Hope that helps, or maybe someone has something better.

0 Likes