iqueqiorio iqueqiorio - 17 days ago 4x
Java Question

remove all spaces regrex

I am trying to remove everything inside the "( )" and all spaces in java with regrex I am close here is the string

First Last "(Some stuff)"

And here is my regrex


the only thing it doesnt do it remove the space between first and last?

How can I add that?


You can use altenration to match text inside (..) or spaces:

str = str.replaceAll("\"\\([^)]*\\)\"|\\s+", "");

RegEx Demo