javascript
// \n换行符不能被.匹配
console.log(/foo.bar/.test('fooabar')) // true
console.log(/foo.bar/.test('foo\nbar')) // false
// dotAll
console.log(/foo.bar/su.test('foo\nbar')) // true
const re = /foo.bar/gisu
console.log(re.dotAll) // true
console.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) // 2020
console.log(t.groups.month) // 03
console.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/))