VSCode regex find & replace submatch math?

Rakka Rage picture Rakka Rage · Jan 5, 2016 · Viewed 140.6k times · Source
%s@{fileID: \(213[0-9]*\)@\='{fileID: '.(submatch(1)-1900)@

I am using this regex search and replace command in vim to subtract a constant from each matching id.

I can do the regex find in VSCode but how can I reference the submatch for maths & replace? submatch(1) does not work in VSCode?

Thanks.

Answer

Benjamin Pasero picture Benjamin Pasero · Jan 11, 2016

Given a regular expression of (foobar) you can reference the first group using $1 and so on if you have more groups in the replace input field.