//XRegExp 3.0.0-pre-20120914 MIT License var XRegExp=function(p){function A(a,b,d){var c;if(d)if(a.__proto__)a.__proto__=e.prototype;else for(c in e.prototype)a[c]=e.prototype[c];a[g]={captureNames:b};return a}function w(a){return j.replace.call(a,/([\s\S])(?=[\s\S]*\1)/g,"")}function s(a,b){if(!e.isRegExp(a))throw new TypeError("Type RegExp expected");var d=j.exec.call(/\/([a-z]*)$/i,String(a))[1],b=b||{};b.add&&(d=w(d+b.add));b.remove&&(d=j.replace.call(d,RegExp("["+b.remove+"]+","g"),""));return a=A(RegExp(a.source,d),a[g]&&a[g].captureNames? a[g].captureNames.slice(0):null,b.addProto)}function t(a,b){if(Array.prototype.indexOf)return a.indexOf(b);var d=a.length,c;for(c=0;c"}else if(d)return"\\"+ (+d+i);return a},m;if(!u(a,"Array")||!a.length)throw new TypeError("Must provide a nonempty array of patterns to merge");for(m=0;md.index)&&(this.lastIndex=d.index)}this.global||(this.lastIndex=b);return d};l.test=function(a){return!!l.exec.call(this,a)};l.match=function(a){var b;if(e.isRegExp(a)){if(a.global)return b=j.match.apply(this,arguments),a.lastIndex=0,b}else a=RegExp(a);return l.exec.call(a,q(this))};l.replace=function(a,b){var d= e.isRegExp(a),c,f,i;d?(a[g]&&(f=a[g].captureNames),c=a.lastIndex):a+="";i=u(b,"Function")?j.replace.call(String(this),a,function(){var c=arguments,e;if(f){c[0]=new String(c[0]);for(e=0;ea.length-3)throw new SyntaxError("Backreference to undefined group "+b);return a[c]||""}throw new SyntaxError("Invalid token "+b);})});d&&(a.lastIndex=a.global?0:c);return i};l.split=function(a,b){if(!e.isRegExp(a))return j.split.apply(this,arguments);var d=String(this),c=[],f=a.lastIndex, g=0,h,b=(b===p?-1:b)>>>0;e.forEach(d,a,function(a){a.index+a[0].length>g&&(c.push(d.slice(g,a.index)),1b?c.slice(0,b):c};n=e.addToken;n(/\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4})|x(?![\dA-Fa-f]{2}))/,function(a,b){if("B"===a[1]&&"default"===b)return a[0];throw new SyntaxError("Invalid escape "+ a[0]);},{scope:"all"});n(/\[(\^?)]/,function(a){return a[1]?"[\\s\\S]":"\\b\\B"});n(/\(\?#[^)]*\)/,function(a,b,d){return C(a.input,a.index+a[0].length,d)?"":"(?:)"});n(/\s+|#.*/,function(a,b,d){return C(a.input,a.index+a[0].length,d)?"":"(?:)"},{flag:"x"});n(/\./,function(){return"[\\s\\S]"},{flag:"s"});n(/\\k<([\w$]+)>/,function(a){var b=isNaN(a[1])?t(this.captureNames,a[1])+1:+a[1],d=a.index+a[0].length;if(!b||b>this.captureNames.length)throw new SyntaxError("Backreference to undefined group "+ a[0]);return"\\"+b+(d===a.input.length||isNaN(a.input.charAt(d))?"":"(?:)")});n(/\\(\d+)/,function(a,b){if(!("default"===b&&/^[1-9]/.test(a[1])&&+a[1]<=this.captureNames.length)&&"0"!==a[1])throw new SyntaxError("Cannot use octal escape or backreference to undefined group "+a[0]);return a[0]},{scope:"all"});n(/\(\?P?<([\w$]+)>/,function(a){if(!isNaN(a[1]))throw new SyntaxError("Cannot use integer as capture name "+a[0]);if("length"===a[1]||"__proto__"===a[1])throw new SyntaxError("Cannot use reserved word as capture name "+ a[0]);if(-1