Intl.js
Intl.js copied to clipboard
IE10 "Syntax error in regular expression" when using DatePipe in Angular 2
This may not be Angular 2 specific, but I am using angular-cli 1.0.0 with intl polyfills:
import 'intl';
import 'intl/locale-data/jsonp/sk-SK.js';
When formatting with date pipe, itl crashes with "Syntax error in regular expression". It happens after regex optimization in intl:
// Shorten the regex by replacing each part of the expression with a match
// for a string of that exact length. This is safe for the type of
// expressions generated above, because the expression matches the whole
// match string, so we know each group and each segment between capturing
// groups can be matched by its length alone.
var exprStr = exprStr.replace(/(\\\(|\\\)|[^()])+/g, function (match) {
return '[\\s\\S]{' + match.replace('\\', '').length + '}';
});
If I comment out this reqex shortening, everything is working fine.
Example of exprStr that is incorrectly shortened before shortening:
\\\{\\((((((((())))))))\})
After:
[\s\S]{6}(((((((())))))))[\s\S]{1})
Did you try to disabled the regexp cache? More details here: https://github.com/andyearnshaw/Intl.js#locale-data, read the second paragraph, and let us know.
Yes, disabling the regexp cache helps. I did not find it previously, but the same issue with Date pipe was mentioned in #231