Does Firefox regular not support pre-assertion?

the following code:

let exp = null;
try {
    // firefox make this error
    exp = new RegExp("(?<!\\$)\\$(\\d+|\\w+?\\b)", "g");
} catch (error) {
    exp = new RegExp("\\$(\\d+|\\w+?\\b)", "g");
}

/**
 * 
 * 
 * @param {String} format 
 * @param  {...any} args 
 */
export default function printf(format, ...args) {

    return format.replace(exp, function (target, name) {
        if (args.length === 1 && args[0] instanceof Object) {
            return args[0][name] || target;
        } else {
            return args[name] || target;
        }
    });
}

now I wonder if bug feels that Firefox parses the prefix as a group

.
Aug.08,2021

not supported, this is the latest feature
https://developer.mozilla.org.
according to mdn, currently only chrome and opera support preassertions


is there any solution?

Menu