=Og>VdZddlZddlmZmZddlZgdZdZejej ej ej Gdd Z ej Z d!d Zd!d Zd!d Zd"d Zd"dZd"dZd!dZd!dZd!dZdZd!dZddDZdZeejddZeejdddZiZdZdZ ej!edZ"dZ#dZ$ddl%Z%dZ&e%j'ee&e Gdd Z(dS)#aSupport for regular expressions (RE). This module provides regular expression matching operations similar to those found in Perl. It supports both 8-bit and Unicode strings; both the pattern and the strings being processed can contain null bytes and characters outside the US ASCII range. Regular expressions can contain both special and ordinary characters. Most ordinary characters, like "A", "a", or "0", are the simplest regular expressions; they simply match themselves. You can concatenate ordinary characters, so last matches the string 'last'. The special characters are: "." Matches any character except a newline. "^" Matches the start of the string. "$" Matches the end of the string or just before the newline at the end of the string. "*" Matches 0 or more (greedy) repetitions of the preceding RE. Greedy means that it will match as many repetitions as possible. "+" Matches 1 or more (greedy) repetitions of the preceding RE. "?" Matches 0 or 1 (greedy) of the preceding RE. *?,+?,?? Non-greedy versions of the previous three special characters. {m,n} Matches from m to n repetitions of the preceding RE. {m,n}? Non-greedy version of the above. "\\" Either escapes special characters or signals a special sequence. [] Indicates a set of characters. A "^" as the first character indicates a complementing set. "|" A|B, creates an RE that will match either A or B. (...) Matches the RE inside the parentheses. The contents can be retrieved or matched later in the string. (?aiLmsux) The letters set the corresponding flags defined below. (?:...) Non-grouping version of regular parentheses. (?P...) The substring matched by the group is accessible by name. (?P=name) Matches the text matched earlier by the group named name. (?#...) A comment; ignored. (?=...) Matches if ... matches next, but doesn't consume the string. (?!...) Matches if ... doesn't match next. (?<=...) Matches if preceded by ... (must be fixed length). (?rr?s r<rrs" GU # # - -f 5 55r;cHt|||S)ztScan through string looking for a match to the pattern, returning a Match object, or None if no match was found.)r>rr?s r<rrs" GU # # * *6 2 22r;cLt|||||S)aZReturn the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl. repl can be either a string or a callable; if a string, backslash escapes in it are processed. If it is a callable, it's passed the Match object and must return a replacement string to be used.)r>r r@replrAcountrBs r<r r s& GU # # ' 'fe < <r rFs r<r r s& GU # # ( (vu = ==r;cJt||||S)aSplit the source string by the occurrences of the pattern, returning a list containing the resulting substrings. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occur, and the remainder of the string is returned as the final element of the list.)r>r )r@rAmaxsplitrBs r<r r s$ GU # # ) )&( ; ;;r;cHt|||S)aReturn a list of all non-overlapping matches in the string. If one or more capturing groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.)r>r r?s r<r r s" GU # # + +F 3 33r;cHt|||S)zReturn an iterator over all non-overlapping matches in the string. For each match, the iterator returns a Match object. Empty matches are included in the result.)r>r r?s r<r r s" GU # # , ,V 4 44r;c"t||S)zACompile a regular expression pattern, returning a Pattern object.)r>)r@rBs r<rrs GU # ##r;cjttdS)z#Clear the regular expression cachesN)_cacheclear _compile_repl cache_clearr:r;r<rrs' LLNNNr;cddl}|dt|5|dtt ||t zcdddS#1swxYwYdS)zBCompile a template pattern, returning a Pattern object, deprecatedrNzThe re.template() function is deprecated as it is an undocumented function without an obvious purpose. Use re.compile() instead.ignore)warningswarnDeprecationWarningcatch_warnings simplefilterr>r3)r@rBrVs r<rrsOOO MM.% &&&  " "**h(:;;;q))******************s3A44A8;A8c4i|]}|dt|zS)\)chr).0is r< r`s$RRR1aARRRr;s()[]{}?*+-|^$\.&~# ct|tr|tSt|d}|tdS)z0 Escape special characters in a string. latin1) isinstancestr translate_special_chars_mapencode)r@s r<rrs^'3F  !3444gx((  !344;;HEEEr;ict|tr|j} tt |||fS#t $rYnwxYwt|t r|rtd|Stj |std|tzrddl }| dttj||}|t zs}t#tt$krF tt't)t=n#t*t,t f$rYnwxYw|tt |||f<|S)Nz5cannot process flags argument with a compiled patternz1first argument must be string or compiled patternrzoThe re.TEMPLATE/re.T flag is deprecated as it is an undocumented flag without an obvious purpose. Don't use it.)rcr$valuerPtypeKeyErrorr ValueErrorrisstring TypeErrorr3rVrWrXrr5len _MAXCACHEnextiter StopIteration RuntimeError)r@rBrVps r<r>r>sz%##  d7mmWe344      '7##  IGII I  g & &MKLLL qy& "%  & & & '5))A EM2 v;;) # # 4V --..!<:    01tG}}gu,- Hs!; AA<'D$$D>=D>c,tj||SN)rparse_template)rGr@s r<rRrR1s  !$ 0 00r;cVtj||}tj||Srx)rryexpand_template)r@rrs r<_expandr|6s'%h88H  "8U 3 33r;ct||}|ds't|ddkr|ddS|fd}|S)Nrrc,tj||Srx)rr{)rrs r<filterz_subx..filterAs&x777r;)rRrp)r@rrs r<_subxr;s]Xw//H A;3x{++q00{1~'8888 Mr;c,t|j|jffSrx)r>r@rB)rvs r<_picklerIs ai) ))r;ceZdZddZdZdS)Scannerrcddlm}m}t|tr|j}||_g}tj}||_ |D]w\}}| } | tj ||| ddtj ||ffg|| |dxtj ||d|ffg}tj||_dS)Nr)BRANCH SUBPATTERNr) _constantsrrrcr$rjlexiconrStaterB opengroupappend SubPatternparse closegrouprrscanner) selfrrBrrrvsphraseactiongids r<__init__zScanner.__init__Rs 22222222 eY ' ' KE  MOO% % %NFF++--C HHW'c1avu)E)EFG,    LLae $ $ $ $  qFT1I#6"7 8 8 (++ r;c~g}|j}|j|j}d} |}|snz|}||krn_|j|jdz d}t |r%||_|||}| |||}|||dfS)NrTr)rrrendr lastindexcallablegroup) rrAresultrrr_mjrs r<scanz Scanner.scancs $$V,,2  A AAvv\!+a-03F 1 aggii00!vA vabbz!!r;Nr)r'r(r)rrr:r;r<rrQs7,,,,""""""r;rr)rr))__doc__enumrhrr functools__all__ __version__ global_enum _simple_enumIntFlagKEEPr$rrrrr r r r r rrrrfrrkrrrPrqr> lru_cacherRr|rcopyregrpicklerr:r;r<rs"iiV     4<$)444       54   2222 6666 3333 ==== > > > ><<<<44445555$$$$   * * * *"SR0QRRRFFF $ y Q'' ( (  Y r1 % % + +B / /00      BY11 1444 ***w*** %"%"%"%"%"%"%"%"%"%"r;