RegExp.prototype.match()
此方法检索匹配项。
语法 (Syntax)
str.match(regexp)
参数的细节 (Parameter Details)
Regexp - 正则表达式对象。
返回值 (Return Value)
返回匹配数组,如果未找到匹配项,则返回null。
例子 (Example)
var str = 'Welcome to ES6.We are learning ES6';
var re = new RegExp("We");
var found = str.match(re);
console.log(found);
输出 (Output)
We