I'm using the following javascript to parse number according to locale. It works fine, but when it fails the YUI Compressor used to compress js. Apparently, the error is at using the backtick ` in the new RegExp constructor. And it is fine if it's removed.
function myparsenumber(value, locale) {
locale = typeof locale !== 'undefined' ? locale : navigator.language;
var example = Intl.NumberFormat(locale).format('1.1');
var cleanPattern = new RegExp(`[^-+0-9${ example.charAt( 1 ) }]`, 'g');
var cleaned = value.replace(cleanPattern, '');
var normalized = cleaned.replace(example.charAt(1), '.');
return parseFloat(normalized);
}
Is there any equivalent constructor or expression to avoid the backtick? Thanks in advance