RegExp-dotAll

//.不能匹配四个字节的utf16字符和行终止符\n,\r
console.log(/foo.bar/.test(‘foo\nbar‘)) //false

//dotAll
console.log(/foo.bar/us.test(‘foo\nbar‘)) //true

//如何判断正则是否启用了dotAll模式
const re = /foo.bar/s
console.log(re.dotAll) //true
console.log(re.flags)  //s

相关推荐