Home >Web Front-end >JS Tutorial >Regular extension methods in es6 syntax

Regular extension methods in es6 syntax

一个新手
一个新手Original
2017-09-29 09:28:101574browse

{
    //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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn