Syntax
RegExpObject.test(string)
JS中正则表达式pattern写在两个顺斜杠之间 .
Example
Do a global search, and test for "Hello" and "W3Schools" in a string:
The output of the code above will be:
Returned value: true
Returned value: false
var val="abc def 134";
val.replace(/\W/g, "");//去空格
阅读(1501) | 评论(1) | 转发(0) |