Replacement
When replacing text, certain sequences have special meaning. RegExPlus includes each syntax supported by Java, and adds some of its own.
By number - $n
Each occurrence of $n
will be replaced with the
nth capture group.
The first number after the $ is always treated as part of the group reference. Subsequent numbers are incorporated into n if they would form a legal group reference.
By name - $<name>
Each occurrence of $<name>
will be replaced
with the text captured by the given named group.
This syntax is used in Java 7 to refer to named capture groups.
General syntax - ${n | name | group}
This syntax provides a general syntax to refer to named and unnamed groups, alike.
If a number is specified, ${n}
,
the replaced string is the nth capture group.
If a name is specified, ${name}
,
the replaced string is the capture group with the given name.
If a group is specified ${groupName[occurrence]}
,
the replaced string is the specified capture group.
Numbered groups
When using the general syntax, there is no way to refer to a numbered group (a group whose name consists of only digits).