Closed spaceemotion closed 3 months ago
Your isSupported
function should work great. Probably better is directly running regex``;
behind your try catch, rather than new RegExp('', 'v');
. You could also check for the existence of RegExp.prototype.unicodeSets
so you don't need try
/catch
.
As of v2.1.0, regex
no longer relies on native support for flag v and works in much older browsers (see details in the readme under "Compatibility"). Testing for support should no longer be needed.
I stumbled over this package as I was trying to improve the performance of our RegExes and noticed the disclaimer about the
v
flag that's required. I know that not every customer has a "modern" machine, so is there a way to check if this package is supported at all?Something like
isSupported
to check if I can even use this setup would be nice, so that I can implement a fall back for older browsers/systems.I guess one way of doing it is to check via a try-catch, but I am not sure if I am missing anything else: