iqueqiorio iqueqiorio - 3 months ago 13
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