Replace two or more spaces with a single space.

Java :
String oldStr = "AAA   BBB";
String newStr = oldStr.replaceAll(" {2,}", " ");

JS :
var oldStr = "AAA   BBB";
var newStr = oldStr.replace(//s{2,}/g," ");

SQL :
If there two records in table A, the s of A2 is "aa bb" and "aaa   bbb".
We can use the like :
UPDATE A SET A2=REGEXP_REPLACE(A2, '( ){2,}', ' '),
and then the new s of A2 is "aa bb" and "aaa bbb".

相关文章:

  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2021-10-11
  • 2021-09-30
相关资源
相似解决方案