Sublime Forum

Search with Regex and replace with found text

#1

Hello,

is it possible to search with a regular expression and replace it with the found string.
e.g.:
Find: 0[0-9]{4}
Sublime Text found: 01111, 01540 and 05475
Sublime Text should now replace the first char from the found string and add a Zero at the end of the string.
Does it work?

Thanks:)

0 Likes

#2

Yes: use this as your regex:

0([0-9]{4})

and put this in the “replace” box:

${1}0

(press CTRL + SHIFT + F to bring up the advanced search)

More generally, $1 is your first capture group, $2 is your second capture group, and so forth.

0 Likes

#3

Works great:)

Thanks a lot for the good and fast explanation!

1 Like