I would like to insert whitespace(s) into a string if the string is in any of the following format:
(A) => (A)
(A)B => (A) B
A(B) => A (B)
A(B)C => A (B) C
AB(C) => AB (C)
Thank you in advance.
Edit: The replacement should only be done if there are matching parentheses.
AB(C => AB(C should remain as is.
This doesn’t exactly what you do, but almost. This will add spaces before and after everything that’s surrounded by parentheses. Any existing spaces will be replaced by one space. Also finally trailing spaces are removed.
Remark: I’ve only checked the pattern (in Eclipse by the way), might have some minor syntax errors.