In my code, I have type checks.
In this situation, I'm trying to check if something is a RegExp.
value instanceof RegExp
The RegExp check returns false on /^some:thing.*$/ which would be from dev.latvian.mods.rhino.regexp.NativeRegExp
How would I check if a value is a RegExp? I think this approach only catches RexExp s made with new RegExp() (not tested) but it def. doesn't work with /^$/ regexes.
I looked in Rhino's code and didn't find anything to check is something is a RexExp.
Was thinking about doing
let regex = /^tieredshulkers:.*shulker_box((?!upgrade).)*$/;
let str = regex.toString();
let isRegExp = false;
if (str.startsWith('/') && str.lastIndexOf('/') > 0) {
console.log('The string representation of regex looks like a RegExp');
isRegExp = true;
} else {
console.log('The string representation of regex does not look like a RegExp');
}
but this is not the best approach ofc.
