javascript regex summary
js中正则表达式的几种应用场景:
验证
RegExp.prototype.test
提取
String.prototype.match
String.prototype.matchAll
RegExp.prototype.exec
match
/exec
方法,如果没有分组匹配,则通常取matches[0]
,如果有分组匹配,则取matches[1]、matches[2]...
替换
String.prototype.replace
String.prototype.replaceAll
拆分
String.prototype.split