inputmask.regex.extensions.min.js 2.8 KB

12345678
  1. /*!
  2. * inputmask.regex.extensions.min.js
  3. * http://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2015 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.2.1-13
  7. */
  8. !function(a){"function"==typeof define&&define.amd?define(["jquery","inputmask"],a):"object"==typeof exports?module.exports=a(require("jquery"),require("./inputmask")):a(jQuery,window.Inputmask)}(function(a,b){return b.extendAliases({Regex:{mask:"r",greedy:!1,repeat:"*",regex:null,regexTokens:null,tokenizer:/\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,quantifierFilter:/[0-9]+[^,]/,isComplete:function(a,b){return new RegExp(b.regex).test(a.join(""))},definitions:{r:{validator:function(b,c,d,e,f){function g(a,b){this.matches=[],this.isGroup=a||!1,this.isQuantifier=b||!1,this.quantifier={min:1,max:1},this.repeaterPart=void 0}function h(){var a,b,c=new g,d=[];for(f.regexTokens=[];a=f.tokenizer.exec(f.regex);)switch(b=a[0],b.charAt(0)){case"(":d.push(new g(!0));break;case")":j=d.pop(),d.length>0?d[d.length-1].matches.push(j):c.matches.push(j);break;case"{":case"+":case"*":var e=new g(!1,!0);b=b.replace(/[{}]/g,"");var h=b.split(","),i=isNaN(h[0])?h[0]:parseInt(h[0]),k=1===h.length?i:isNaN(h[1])?h[1]:parseInt(h[1]);if(e.quantifier={min:i,max:k},d.length>0){var l=d[d.length-1].matches;a=l.pop(),a.isGroup||(j=new g(!0),j.matches.push(a),a=j),l.push(a),l.push(e)}else a=c.matches.pop(),a.isGroup||(j=new g(!0),j.matches.push(a),a=j),c.matches.push(a),c.matches.push(e);break;default:d.length>0?d[d.length-1].matches.push(b):c.matches.push(b)}c.matches.length>0&&f.regexTokens.push(c)}function i(b,c){var d=!1;c&&(l+="(",n++);for(var e=0;e<b.matches.length;e++){var f=b.matches[e];if(f.isGroup===!0)d=i(f,!0);else if(f.isQuantifier===!0){var g=a.inArray(f,b.matches),h=b.matches[g-1],j=l;if(isNaN(f.quantifier.max)){for(;f.repeaterPart&&f.repeaterPart!==l&&f.repeaterPart.length>l.length&&!(d=i(h,!0)););d=d||i(h,!0),d&&(f.repeaterPart=l),l=j+f.quantifier.max}else{for(var k=0,m=f.quantifier.max-1;m>k&&!(d=i(h,!0));k++);l=j+"{"+f.quantifier.min+","+f.quantifier.max+"}"}}else if(void 0!==f.matches)for(var p=0;p<f.length&&!(d=i(f[p],c));p++);else{var q;if("["==f.charAt(0)){q=l,q+=f;for(var r=0;n>r;r++)q+=")";var s=new RegExp("^("+q+")$");d=s.test(o)}else for(var t=0,u=f.length;u>t;t++)if("\\"!==f.charAt(t)){q=l,q+=f.substr(0,t+1),q=q.replace(/\|$/,"");for(var r=0;n>r;r++)q+=")";var s=new RegExp("^("+q+")$");if(d=s.test(o))break}l+=f}if(d)break}return c&&(l+=")",n--),d}var j,k=c.buffer.slice(),l="",m=!1,n=0;null===f.regexTokens&&h(),k.splice(d,0,b);for(var o=k.join(""),p=0;p<f.regexTokens.length;p++){var q=f.regexTokens[p];if(m=i(q,q.isGroup))break}return m},cardinality:1}}}}),b});