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".
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。