正则表达式将字符串中的所有连续空格替换成一个空格

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".

相关文章

jquery.validate使用攻略(表单校验) 目录 jquery.validate...
/\s+/g和/\s/g的区别 正则表达式/\s+/g...
自整理几个jquery.Validate验证正则: 1. 只能输入数字和字母...
this.optional(element)的用法 this.optional(element)是jqu...
jQuery.validate 表单动态验证 实际上jQuery.validate提供了...
自定义验证之这能输入数字(包括小数 负数 ) <script ...