External JavaScript File does not load in Safari due to “invalid” regular expression

I’m new to JavaScript and my first project was to create a Unit Converter. All the functions for the converting are stored in an external js-File. If the user enters a value in an input field all the other input fields automatically output the converted values.

Link to my site: https://uc.jz-apps.ch

It perfectly works in Firefox, Chrome and Edge but unfortunately not in Safari. It seems the js-File is not loading. I checked the console output in Safari using crossbrowsertesting.com and it seems the file is not loading due to an “invalid” regular expression.

Console output:

SyntaxError: Invalid regular expression: invalid group specifier name (anonymous function) – functions.js:64

I use a function to “clean” the converted values before outputting them, like searching and replacing NaN values and also add a thousand seperator (‘) which is based on the regular expression mentioned in the console output.

Here is the code of my function:

function cleanValues(value) {
    const formatNum = num =>
        String(num).replace(/(?<!..*)(d)(?=(?:d{3})+(?:.|$))/g, "$1'");

    if (isNaN(parseFloat(value))) {
        value = "";
    }

    return formatNum(value);
}

And here is an example of calling the function when calculating the values:

fahrenheit.value = cleanValues((fieldValue * 1.8) +32);

I’m not familiar yet with regular expressions so I just copied it from another stackoverflow user. I have no idea if it’s valid but it does what it should do in Firefox, Chrome and Edge.

What could be the problem with Safari? I’m thankful for every idea and workaround to fix my code/regexp to make it work in Safari as well.