In my program when I\'m using
line.replaceAll(\"(\", \"_\");
I got a RuntimeException
:
at java.util.regex.Pattern
The first argument to string.replaceAll
is a regular expression, not just a string. The opening left bracket is a special character in a regex, so you must escape it:
line.replaceAll("\\(", "_");
Alternatively, since you are replacing a single character, you could use string.replace
like so:
line.replace('(', '_');