Home >Web Front-end >JS Tutorial >Regular extension methods in es6 syntax
{ //es5中let regex = new RegExp('xyz','i'); let regex2 = new RegExp(/xyz/i); console.log(regex.test('xyz123'),regex2.test('xyz123')); // true,true //es6中,flags是新增的,获取正则对象修饰符let regex3 = new RegExp(/xyz/ig,'i'); console.log(regex3.flags); // i 后一个覆盖前面的 }
The above is the detailed content of Regular extension methods in es6 syntax. For more information, please follow other related articles on the PHP Chinese website!