ES2018:RegExp 新功能介紹
/s flag 為了解決目前的 dot(.) 無法比對到換行字元,因此新的 /s flag 又稱 dotAll mode。 const input = ` Lorem ipsum dolor sit amet, consectetur adipiscing hello world elit. Nam sit amet elit id risus aliquam porta. `; /hello.world/u.test(input); // false workarounds: /hello[\s\S]world/u.test(input); // true /hello[^]world/u.test(input) // true 新語法
…
Read more
Read more