var XRegExp;if(XRegExp){throw Error("can't load XRegExp twice in the same frame");} (function(undefined){XRegExp=function(pattern,flags){var output=[],currScope=XRegExp.OUTSIDE_CLASS,pos=0,context,tokenResult,match,chr,regex;if(XRegExp.isRegExp(pattern)){if(flags!==undefined) throw TypeError("can't supply flags when constructing one RegExp from another");return clone(pattern);} if(isInsideConstructor) throw Error("can't call the XRegExp constructor within token definition functions");flags=flags||"";context={hasNamedCapture:false,captureNames:[],hasFlag:function(flag){return flags.indexOf(flag)>-1;},setFlag:function(flag){flags+=flag;}};while(pos1&&indexOf(match,"")>-1){r2=RegExp(this.source,nativ.replace.call(getNativeFlags(this),"g",""));nativ.replace.call((str+"").slice(match.index),r2,function(){for(var i=1;imatch.index)) this.lastIndex--;} if(!this.global) this.lastIndex=origLastIndex;return match;};RegExp.prototype.test=function(str){var match,origLastIndex;if(!this.global) origLastIndex=this.lastIndex;match=nativ.exec.call(this,str);if(match&&!compliantLastIndexIncrement&&this.global&&!match[0].length&&(this.lastIndex>match.index)) this.lastIndex--;if(!this.global) this.lastIndex=origLastIndex;return!!match;};String.prototype.match=function(regex){if(!XRegExp.isRegExp(regex)) regex=RegExp(regex);if(regex.global){var result=nativ.match.apply(this,arguments);regex.lastIndex=0;return result;} return regex.exec(this);};String.prototype.replace=function(search,replacement){var isRegex=XRegExp.isRegExp(search),captureNames,result,str,origLastIndex;if(isRegex){if(search._xregexp) captureNames=search._xregexp.captureNames;if(!search.global) origLastIndex=search.lastIndex;}else{search=search+"";} if(Object.prototype.toString.call(replacement)==="[object Function]"){result=nativ.replace.call(this+"",search,function(){if(captureNames){arguments[0]=new String(arguments[0]);for(var i=0;iargs.length-3){literalNumbers=String.prototype.slice.call($1,-1)+literalNumbers;$1=Math.floor($1/10);} return($1?args[$1]||"":"$")+literalNumbers;}}else{var n=+$2;if(n<=args.length-3) return args[n];n=captureNames?indexOf(captureNames,$2):-1;return n>-1?args[n+1]:$0;}});});} if(isRegex){if(search.global) search.lastIndex=0;else search.lastIndex=origLastIndex;} return result;};String.prototype.split=function(s,limit){if(!XRegExp.isRegExp(s)) return nativ.split.apply(this,arguments);var str=this+"",output=[],lastLastIndex=0,match,lastLength;if(limit===undefined||+limit<0){limit=Infinity;}else{limit=Math.floor(+limit);if(!limit) return[];} s=XRegExp.copyAsGlobal(s);while(match=s.exec(str)){if(s.lastIndex>lastLastIndex){output.push(str.slice(lastLastIndex,match.index));if(match.length>1&&match.index=limit) break;} if(s.lastIndex===match.index) s.lastIndex++;} if(lastLastIndex===str.length){if(!nativ.test.call(s,"")||lastLength) output.push("");}else{output.push(str.slice(lastLastIndex));} return output.length>limit?output.slice(0,limit):output;};function clone(regex,additionalFlags){if(!XRegExp.isRegExp(regex)) throw TypeError("type RegExp expected");var x=regex._xregexp;regex=XRegExp(regex.source,getNativeFlags(regex)+(additionalFlags||""));if(x){regex._xregexp={source:x.source,captureNames:x.captureNames?x.captureNames.slice(0):null};} return regex;} function getNativeFlags(regex){return(regex.global?"g":"")+ (regex.ignoreCase?"i":"")+ (regex.multiline?"m":"")+ (regex.extended?"x":"")+ (regex.sticky?"y":"");} function runTokens(pattern,index,scope,context){var i=tokens.length,result,match,t;isInsideConstructor=true;try{while(i--){t=tokens[i];if((scope&t.scope)&&(!t.trigger||t.trigger.call(context))){t.pattern.lastIndex=index;match=t.pattern.exec(pattern);if(match&&match.index===index){result={output:t.handler.call(context,match,scope),match:match};break;}}}}catch(err){throw err;}finally{isInsideConstructor=false;} return result;} function indexOf(array,item,from){if(Array.prototype.indexOf) return array.indexOf(item,from);for(var i=from||0;i/,function(match){this.captureNames.push(match[1]);this.hasNamedCapture=true;return "(";});XRegExp.addToken(/\\k<([\w$]+)>/,function(match){var index=indexOf(this.captureNames,match[1]);return index>-1?"\\"+(index+1)+(isNaN(match.input.charAt(match.index+match[0].length))?"":"(?:)"):match[0];});XRegExp.addToken(/\[\^?]/,function(match){return match[0]==="[]"?"\\b\\B":"[\\s\\S]";});XRegExp.addToken(/^\(\?([imsx]+)\)/,function(match){this.setFlag(match[1]);return "";});XRegExp.addToken(/(?:\s+|#.*)+/,function(match){return nativ.test.call(quantifier,match.input.slice(match.index+match[0].length))?"":"(?:)";},XRegExp.OUTSIDE_CLASS,function(){return this.hasFlag("x");});XRegExp.addToken(/\./,function(){return "[\\s\\S]";},XRegExp.OUTSIDE_CLASS,function(){return this.hasFlag("s");});})();