Reputation: 3
What's the regex for removing parentheses and everything between?
input = "hello world (this is a test1) (test 2) hello";
output = "hello world hello";
I tried:
str.replaceAll("//(.*?//)", "");
Upvotes: 0
Views: 63
Reputation: 72844
You are using forward slash characters to escape the (
and )
special characters. You need to use backslashes:
String output = input.replaceAll("\\(.*?\\)", "");
Upvotes: 1