javascript正则表达式

  • 去掉首位空格

str=str.replace(/^s+|s+$/g,''); 

  • 替换非数字

this.value=this.value.replace(/D/g,'')

原文地址:https://www.cnblogs.com/azhqiang/p/3992002.html