@Nonnull
		private String getReplacement(int index) {
			String replacement = replaceInput.getText();
			Match match = resultRanges.get(index);
			String[] groups = match.groups();
			if (groups != null) {
				// Record '$N' patterns in the string
				//  - 0: whole matched text
				//  - N: group N's text
				Matcher matcher = RegexUtil.getMatcher("(?<!\\\\)(?:(\\\\\\\\)*)\\$\\d+", replacement);
				while (matcher.find()) {
					int groupId = Integer.parseInt(matcher.group(0).replaceAll("\\D+", ""));
					if (groupId < groups.length) {
						String groupText = groups[groupId];
						replacement = replacement.replace("$" + groupId, groupText);
					}
				}
			}
			return replacement;
		}
if {@link #regex} is {@code true}, then transformations are made on the replacement text from
{@link #replaceInput} to support regex groups.
<br>
For example:
<ul>
    <li>Search: {@code public (class)}</li>
    <li>Replace: {@code private $1}</li>
    <li>Yields: {@code private class}</li>
</ul>

@param index
		Index in {@link #resultRanges} to replace.

@return Replacement for the given range.
recaf-ui/src/main/java/software/coley/recaf/ui/control/richtext/search/SearchBar.java