/*! * XRegExp Addon for PHP * Adds some Tokens that are not supported.XregEXp but exists with PHP PCRE */ (function (XRegExp) { if(!window.XRegExp || window.XRegExp.version[0] < '2' ) return; //we don't care about the other versions. //Change ++ into + XRegExp.addToken( /([^\\][\*\?\+])(\+)/, function (match, scope) { return match[1]; },{scope: "all"} ); //strip off the u. XRegExp.addToken(null, null, {customFlags: "u"}); ///////////////////// UNICODE //////////////////////// if (!XRegExp.addUnicodePackage) return; //guard: stop here if unicode support is not available var unicodeshorts = {}; //collection(cash) of regexes var shorts = "CLMNPSZ"; //fetch unicode regexes from XRegExp private into our cash for( var i = 0; i < shorts.length; i++){ var r = XRegExp('\\p{' + shorts[i] + '}').toString(); unicodeshorts[shorts[i]] = r.substr(2, r.length -4);//strip of characterclass [] and delimiters. } //Support for single P without Curly Brackets. XRegExp.addToken( /\\([pP])([CLMNPSZ])/, function (match, scope) { var e = unicodeshorts[match[2]]; return scope==='class'? e : '[' + e + ']'; },{scope: "all"} ); }(XRegExp));