Backslash has a special meaning in
Java source code, so you have to escape it by doubling it. But backspace also has a special meaning in regular expressions, so you have to double it
again. Try this:
"^(19|20)\\d{2}$".replaceAll("\\\\", "\\\\\\\\");