正则表达式收藏

Posted zyg316

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了正则表达式收藏相关的知识,希望对你有一定的参考价值。

去除所有空格:   
str   =   str.replace(/s+/g,"");       
去除两头空格:   
str   =   str.replace(/^s+|s+$/g,"");
去除左空格:
str=str.replace( /^s*/, ‘‘);
去除右空格:
str=str.replace(/(s*$)/g, "");

以上是关于正则表达式收藏的主要内容,如果未能解决你的问题,请参考以下文章