// \n换行符不能被.匹配console.log(/foo.bar/.test("fooabar")); // trueconsole.log(/foo.bar/.test("foo\nbar")); // false// dotAllconsole.log(/foo.bar/su.test("foo\nbar")); // trueconst re = /foo.bar/gisu;console.log(re.dotAll); // trueconsole.log(re.flags); // gisu// const t = "2020-03-28".match(/(\d{4})-(\d{2})-(\d{2})/);// console.log(t[1]); // 2020// console.log(t[2]); // 03// console.log(t[3]); // 28// 命名分组捕获const t = "2020-03-28".match(/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/);console.log(t.groups.year); // 2020console.log(t.groups.month); // 03console.log(t.groups.day); // 28// 断言let test = "hello world";console.log(test.match(/hello(?=\sworld)/));// ?<= 等于 ?<!不等于console.log(test.match(/(?<=hello\s)world/));console.log(test.match(/(?<!helle\s)world/));