Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace regular expression placeholder followed by number in Sublime Text 2

Let's say I want to add a 0 after every word

(\w+)

The following replacement string doesn't work.

$10

So, how do I convert

this is my string

into

this0 is0 my0 string0
like image 934
Andras Gyomrey Avatar asked Sep 02 '25 14:09

Andras Gyomrey


1 Answers

Use braces around the group ID in the replacement string:

${1}0

The braces tell the regex engine that the number inside them is the actual Group ID. The 0 that will follow will be treated as a literal zero.

enter image description here

BTW, you can also get the same result with \w+ regex and ${0}0 replacement string, no need in capturing groups.

Or, using \n syntax, it works like this:

   Find: (\w+)
Replace: \10

enter image description here

like image 178
Wiktor Stribiżew Avatar answered Sep 05 '25 10:09

Wiktor Stribiżew