ES6 - RegExp match() 方法
此方法检索匹配项。
语法
str.match(regexp)
参数详细信息
Regexp − 正则表达式对象。
返回值
返回匹配项数组,如果未找到匹配项,则返回 null。
示例
var str = 'Welcome to ES6.We are learning ES6'; var re = new RegExp("We"); var found = str.match(re); console.log(found);
输出
We
此方法检索匹配项。
str.match(regexp)
Regexp − 正则表达式对象。
返回匹配项数组,如果未找到匹配项,则返回 null。
var str = 'Welcome to ES6.We are learning ES6'; var re = new RegExp("We"); var found = str.match(re); console.log(found);
We
如果您发现内容有误或提出修改建议,请随时向我们发送 E-mail 邮件:
421660149@qq.com
您的建议已发送到 W3schools。