I would like to test for Unicode Regex Property Escapes to avoid compiling a broken regular expression in browsers that do not support it (for example IE11). Ideally, I\'d like
If you feel comfortable with something like Function
or eval
, and a try/catch
...something like this should work:
try {
return new Function('', 'return /\\p{Script=Greek}/u;')()
} catch(e) { return /asdf/g;}
Note you have to escape the \\p
because it's contained in a string now. Tested this on IE11 and it worked (fell back without a fatal parsing error)