码迷,mamicode.com
首页 > Web开发 > 详细

JS正则

时间:2018-07-10 20:08:24      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:wan   数字   undefined   fas   exe   ups   fine   test   .exe   

test     判断字符串是否符合规定的正则

exec   获取匹配的数据

 

例子:

test例子

rep = /\d+/;      //只要有数字就返回true
rep.test("asdkfasdkf9999")
true
rep.test("asdkfasdkf")
false

rep = /^\d+$/;   //全部是数字返回真

 

exec例子

rep = /\d+/;
rep.exec(str);
["88", index: 6, input: "wangn_88_skjffaf_33", groups: undefined]

 

JS正则

标签:wan   数字   undefined   fas   exe   ups   fine   test   .exe   

原文地址:https://www.cnblogs.com/brownyangyang/p/9291007.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!