Find and Replace with Regex


First I’m sorry, I’ve been looking for this here and in others links but i didn’t get it yet.

I’m having difficulties to replace different strings but with the same pattern using an specific regex.

Follow some examples:


And here’s the change that I need:

model="{{ }}“
model=”{{ data.age }}“
model=”{{ data.more.some }}"

So, I’m using the expression (\model="data.*?\") to find those strings, but i’m not understanding how replace without loose the middle value.

I saw something related using $1, maybe this could be the position if I use something like:


I would have $1 and $2? I don’t know.

Hope someone could explain that.


You can use grouped parts of Your regex (those inside parenthesis) in replacing phase with ${group_number} expression. So I grouped only thing that varies in your example and used it in replacing, in order not to lose variable data.

Find: model="data([^"]*)"
Replace: model="{{ data$1 }}"


lol, have just tried something like that.

Find: ^model="data(.*?)"
Replace: model="{{ data$1 }}"

It seems worked.

Anyway thanks for your time.