My program receives code with some regex escape sequences built into the code as two ascii chars. I would like to consolidate those two chars into a single escape sequence.
String testString = "Message\\nline break,\\n\\tline break and tab";
// this shows what I want, but it is hard coded for only two conditions.
System.out.println(testString.replaceAll("\\\\n", "\n").replaceAll("\\\\t", "\t"));
// What I would like to do is something like this, but I either end up escaping the group lookup, generate two chars, or create a parser error.
Are there any good ways that Regex can be used to create an escape sequence from a group match?