1. // \n换行符不能被.匹配
    2. console.log(/foo.bar/.test("fooabar")); // true
    3. console.log(/foo.bar/.test("foo\nbar")); // false
    4. // dotAll
    5. console.log(/foo.bar/su.test("foo\nbar")); // true
    6. const re = /foo.bar/gisu;
    7. console.log(re.dotAll); // true
    8. console.log(re.flags); // gisu
    9. // const t = "2020-03-28".match(/(\d{4})-(\d{2})-(\d{2})/);
    10. // console.log(t[1]); // 2020
    11. // console.log(t[2]); // 03
    12. // console.log(t[3]); // 28
    13. // 命名分组捕获
    14. const t = "2020-03-28".match(/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/);
    15. console.log(t.groups.year); // 2020
    16. console.log(t.groups.month); // 03
    17. console.log(t.groups.day); // 28
    18. // 断言
    19. let test = "hello world";
    20. console.log(test.match(/hello(?=\sworld)/));
    21. // ?<= 等于 ?<!不等于
    22. console.log(test.match(/(?<=hello\s)world/));
    23. console.log(test.match(/(?<!helle\s)world/));