It is unfortunate the the replacement string for RegexReplaceProcessorFactory is a pure, "quoted" (escaped) literal and does not support pattern capture group substitution. This processor should be enhanced to support full, standard pattern capture group substitution.
The test case I used:
Indexing with this command against the standard Solr example with the above addition to solrconfig:
Alas, the resulting document consists of:
The Javadoc for RegexReplaceProcessorFactory uses the exact same terminology of "replacement string", as does Java's Matcher.replaceAll, but clearly the semantics are distinct, with replaceAll supporting pattern capture group substitution for its "replacement string", while RegexReplaceProcessorFactory interprets "replacement string" as being a literal. At a minimum, the RegexReplaceProcessorFactory Javadoc should explicitly state that the string is a literal that does not support pattern capture group substitution.
The relevant code in RegexReplaceProcessorFactory#init:
Possible options for the enhancement:
1. Simply skip the quoteReplacement and fully support pattern capture group substitution with no additional changes. Does have a minor backcompat issue.
2. Add an alternative to "replacement", say "nonQuotedReplacement" that is not quoted as "replacement" is.
3. Add an option, say "quotedReplacement" that defaults to "true" for backcompat, but can be set to "false" to support full replaceAll pattern capture group substitution.