Search and replace with regular expressions in VS Code

I wanted to replace all instances of this:

`#90 <>`__

With this:


For sqlite-utils issue #306.

I used the VS Code's Find and Replace tool with regular expression mode turned on (the .* button). I used the following for the find:

`#(\d+) <\1>`__

Note the \1 reference to say "the same thing I captured earlier with parenthesis". Then I used this as the replace string:


Here the $1 means "the first thing captured with parenthesis".

Screenshot of the find and replace dialog

The resulting change can be seen in commit e83aef95.

Created 2021-08-02T14:30:11-07:00 · Edit