Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression to replace content between parentheses ()

I tried this code:

string.replaceAll("\\(.*?)","");

But it returns null. What am I missing?

like image 943
Praneel PIDIKITI Avatar asked Apr 12 '11 13:04

Praneel PIDIKITI


1 Answers

Try:

string.replaceAll("\\(.*?\\)","");

You didn't escape the second parenthesis and you didn't add an additional "\" to the first one.

like image 112
Mike Thomsen Avatar answered Sep 29 '22 00:09

Mike Thomsen