I'm trying to convert the
java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
But you don't necessarily need regex for this, simply because you want an exact character-by-character replacement and you don't need patterns here. So
String#replace() should suffice:
StringEscapeUtils#escapeEcmaScript() instead to cover more characters.