Is there a fix/callback for browsers that do not support lookbehind?
The only thing I found was a way to detect whether lookbehind is supported or not, but doesn't give an alternative. (See code below)
I'm looking for something that detects whether a lookbehind is entered in a input box and provides an alternative. Even better still when the lookbehind is handled in the background.
I know regex101 is able to handle lookbehinds on older browsers but I wasn't able to figure out how it's done.
An example lookbehind is as follows:
(?<!\n)-
This one matches a dash of not at the beginning of a string. (The string is multined
in a textarea)
var isLookBehindSupported = false;
try {
isLookBehindSupported = !!new RegExp("(?<=)");
} catch (e) {
/*In unsupported browsers, trying to create a lookbehind expression will simply error, which is caught here*/
}
if (isLookBehindSupported) {
// Yay, lookbehind expressions are supported
}
else {
// Booo! Lookbehind not supported
}