代码如下: public static void main(String[] args) { String sql = “SELECT * FROM \n” + ” `testdb`.`foo` LIMIT 0, 100″; String s = “SELECT * FROM `testdb`.`foo` LIMIT 0, 100”; String sql2 = Pattern.compile(” {2,}”).matcher(s).replaceAll(” “); String sql3 = s.replaceAll(” {2,}”,” “); String sql4 = sql.repla