正则表达式

RegExp 类型
test()
var a = /cat/g.test('catalog');
console.log(a) // true

var a = new RegExp('cat', 'g');
var b = a.test('catalog');
console.log(b); // true

exec()
var text = 'mom and dad and bady';
var pattern = /.om/g;
var matches = pattern.exec(text);
console.log(matches[0]); // mom

posted on 2018-03-19 22:18  winerss  阅读(53)  评论(0)    收藏  举报

导航