Browse Source

enhance the regex entension (a bit)

Robin Herbots 12 years ago
parent
commit
342e75ffe9
1 changed files with 9 additions and 6 deletions
  1. 9 6
      js/jquery.inputmask.regex.extensions.js

+ 9 - 6
js/jquery.inputmask.regex.extensions.js

@@ -21,11 +21,14 @@ Allows for using regular expressions as a mask
                     validator: function (chrs, buffer, pos, strict, opts) {
 
                         function analyseRegex() {  //ENHANCE ME
-                            opts.regexSplit = [];
-                            if (opts.regex.indexOf("*") != (opts.regex.length - 1)) {
-                                opts.regex += "{1}";
-                            }
-                            opts.regexSplit.push(opts.regex);
+                            var regexSplitRegex = "\\[.*?\]\\*";
+
+                            opts.regexSplit = opts.regex.match(new RegExp(regexSplitRegex, "g"));
+
+                            //if (opts.regex.indexOf("*") != (opts.regex.length - 1)) {
+                            //    opts.regex += "{1}";
+                            //}
+                            //opts.regexSplit.push(opts.regex);
                         }
 
                         if (opts.regexSplit == null) {
@@ -39,7 +42,7 @@ Allows for using regular expressions as a mask
                             regexPart += opts.regexSplit[i];
                             var exp = new RegExp("^" + regexPart + "$");
                             isValid = exp.test(bufferStr);
-                            console.log(bufferStr + ' ' + isValid);
+                            console.log(bufferStr + ' ' + isValid + ' ' + regexPart);
                             if (isValid) break;
                         }