I’ve used the following regex to try to remove parentheses and everything within them in a string called name.
name.replaceAll("\\(.*\\)", "");
For some reason, this is leaving name unchanged. What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Strings are immutable. You have to do this:
Edit: Also, since the
.*is greedy, it will kill as much as it can. So"(abc)something(def)"will be turned into"".