What’s the correct regex for a plus character (+) as the first argument (i.e. the string to replace) to Java’s replaceAll method in the String class? I can’t get the syntax right.
What’s the correct regex for a plus character (+) as the first argument (i.e.
Share
You need to escape the
+for the regular expression, using\.However, Java uses a String parameter to construct regular expressions, which uses
\for its own escape sequences. So you have to escape the\itself: