Javascript中正则的 match、test、exec使用方法和区别


总结:
match 是String上的方法
test和exec是正则表达式上的方法
test只返回true或false, exec和match的返回结果比较复杂
exec:
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec


match:
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/match
match的结果比较复杂,最好别用这个。。 记住exec就很好了

浙公网安备 33010602011771号