I have this function, and it works fine in all browsers:
cleanKey = function( key ){
return key.replace( /[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g, "-" );
};
However, my ASP.NET MVC 3 project throws a regular expression syntax error when trying to minify that code:
run-time error JS5017: Syntax error in regular expression
/[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g
You might want to try \u037f instead of \u37f since MSDN specifies:
\xn
Matches n, where n is a hexadecimal escape value.
Hexadecimal escape values must be exactly two digits long.
For example, '\x41' matches "A". '\x041' is equivalent to '\x04' & "1".
Allows ASCII codes to be used in regular expressions.\un
Matches n, where n is a Unicode character expressed as four hexadecimal digits.
For example, \u00A9 matches the copyright symbol (©).
Also, I wonder, is this a valid range: \xf8-\u037d (according to asp.net minify tool) ?
You might want to try \u00f8-\u037d instead.
(Maybe add \xf8-\xff to compensate for differences between the upper half of localized code-pages versus Unicode in that region.)
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With