RegEx backreferences in IntelliJ

IntelliJ uses $1 for replacement backreferences.

From IntelliJ's help:

For more information on regular expressions and their syntax, refer to documentation for java.util.regex Back references should have $n, rather than \n format.


In short, you must use $1 to $n for replacement backreferences. \1 syntax is only for backreferences within the search.

In IntelliJ 2016, the in-app documentation is misleading. Here is a better quote from the full docs:

If you need to refer the matched substring somewhere outside the current regular expression (for example, in another regular expression as a replacement string), you can retrieve it using the dollar sign ($num, where num = 1..n).

Source: 2016.1 regular expression syntax, Tips & Tricks