I am facing an issue with minifying a JavaScript file that includes the following working Regex
:
isValid = function (str) {
return !/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g.test(str);
},
The error message states:
/* Minification failed. Returning unminified contents.
(2128,43-44): run-time error JS1004: Expected ';': {
(2128,45-46): run-time error JS1195: Expected expression: |
(2128,46-47): run-time error JS1014: Invalid character: \
(2128,47-48): run-time error JS1014: Invalid character: \
(2128,48-70): run-time error JS1015: Unterminated string constant:
":<>\?]/g.test(str);
(2129,6-7) : run-time error JS1195: Expected expression: ,
(2128,17-43): run-time error JS5017: Syntax error in regular expression:
/[~`!#$%\^&*+=\-\[\]\\';,/
*/
Here is the Bundle Config:
bundles.Add(new ScriptBundle("~/bundlesJs/custom").Include(
"~/Scripts/Autogenerated/AntiHacking/antiHackingHelper.js"
));
BundleTable.EnableOptimizations = true;
What could be the solution to this problem? Do I need to escape a certain character or wrap the entire Regex?