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就很好了

posted @ 2018-08-30 11:14  hh9515  阅读(159)  评论(0编辑  收藏  举报