浏览代码

enhance the regex entension (a bit)

Robin Herbots 12 年之前
父节点
当前提交
342e75ffe9
共有 1 个文件被更改,包括 9 次插入6 次删除
  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;
                         }