假设括号正确平衡且没有嵌套括号,则以下内容将删除括号内(且仅在括号内)的所有空格:
String resultString = subjectString.replaceAll("\s+(?=[^()]*\))", "");它转变
insert into abc values ( e , b );
进入
insert into abc values (e,b);
说明:
s+ # Match whitespace(?= # only if followed by... [^()]* # any number of characters except parentheses ) # and a closing parenthesis) # End of lookahead assertion



