Sublime Forum

Reference a group in search field

#1

Hi !
I’m trying to replace a bunch of lines like:

blablabla REPLACE ME blablabla;FIND ME

On each line, REPLACE ME and FIND ME will have, most of the time, the same content. I just want to replace REPLACE ME with something else. The following regex does not work (it don’t find anything) :

(.+)(?P=foo)(.+);(?P<foo>(.+))

I used the syntax showed there: https://github.com/dmikalova/sublime-cheat-sheets/blob/master/cheat-sheets/Regular%20Expressions.cheatsheet.

Thanks for your help !

0 Likes

#2

Never mind, I just found a simpler way:

Swap the two columns (it’s a csv file) with libreoffice for example, which gives that:

FIND ME;blablabla REPLACE ME blablabla

Then, just use this for search:

(.+);(.+) (\1) (.+)

And this for replace:

$1;$2 something else $4
0 Likes