I have the following string
\Qpipe,name=office1\E
And I am using a simplified regex library that doesn’t support the \Q and \E.
I tried removing them
s.replaceAll("\\Q", "").replaceAll("\\E", "")
However, I get the error Caused by: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 1
\E
^
Any ideas?
\is the special escape character in both Java string and regex engine. To pass a literal\to the regex engine you need to have\\\\in the Java string. So try:Alternatively and a simpler way would be to use the
replacemethod which takes string and not regex: