Home > Web Front-end > JS Tutorial > body text

Regular extension methods in es6 syntax

一个新手
Release: 2017-09-29 09:28:10
Original
1486 people have browsed it

{
    //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 后一个覆盖前面的
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!