B y `~8@s6dZddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8g8Zd9Zd\d=dZd]d>dZd^d?d Zd_d@d Zd`dAdZdadBdZdbdCdZ dcdDd Z dddEd Z dedFdZ dfdGdZ dgdHdZdId ZdJadhdKdZdidLdZdjdMdZd:d;lmZd:d;lmZd:dNlmZd:dOlmZd:dPlTd:dQlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)d:dRlm*Z+m,Z-m.Z/m0Z1m2Z3e4a5e6dSZ7t5e_5iZ8eZ9iZ:iZ;iZdUdVZ?dWdXZ@e?dYd:d...) Atomic non-capturing version of regular parentheses. (?flags-flags:...) Non-capturing version of regular parentheses with local flags. (?P...) The substring matched by the group is accessible by name. (?...) 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 .... (? Matches the text matched by the group named name. \G Matches the empty string, but only at the position where the search started. \h Matches horizontal whitespace. \K Keeps only what follows for the entire match. \L Named list. The list is provided as a keyword argument. \m Matches the empty string, but only at the start of a word. \M Matches the empty string, but only at the end of a word. \n Matches the newline character. \N{name} Matches the named character. \p{name=value} Matches the character if its property has the specified value. \P{name=value} Matches the character if its property hasn't the specified value. \r Matches the carriage-return character. \s Matches any whitespace character; equivalent to [ \t\n\r\f\v]. \S Matches any non-whitespace character; equivalent to [^\s]. \t Matches the tab character. \uXXXX Matches the Unicode codepoint with 4-digit hex code XXXX. \UXXXXXXXX Matches the Unicode codepoint with 8-digit hex code XXXXXXXX. \v Matches the vertical tab character. \w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_] when matching a bytestring or a Unicode string with the ASCII flag, or the whole range of Unicode alphanumeric characters (letters plus digits plus underscore) when matching a Unicode string. With LOCALE, it will match the set [0-9_] plus characters defined as letters for the current locale. \W Matches the complement of \w; equivalent to [^\w]. \xXX Matches the character with 2-digit hex code XX. \X Matches a grapheme. \Z Matches only at the end of the string. \\ Matches a literal backslash. This module exports the following functions: match Match a regular expression pattern at the beginning of a string. fullmatch Match a regular expression pattern against all of a string. search Search a string for the presence of a pattern. sub Substitute occurrences of a pattern found in a string using a template string. subf Substitute occurrences of a pattern found in a string using a format string. subn Same as sub, but also return the number of substitutions made. subfn Same as subf, but also return the number of substitutions made. split Split a string by the occurrences of a pattern. VERSION1: will split at zero-width match; VERSION0: won't split at zero-width match. splititer Return an iterator yielding the parts of a split string. findall Find all occurrences of a pattern in a string. finditer Return an iterator yielding a match object for each match. compile Compile a pattern into a Pattern object. purge Clear the regular expression cache. escape Backslash all non-alphanumerics or special characters in a string. Most of the functions support a concurrent parameter: if True, the GIL will be released during matching, allowing other Python threads to run concurrently. If the string changes during matching, the behaviour is undefined. This parameter is not needed when working on the builtin (immutable) string classes. Some of the functions in this module take flags as optional parameters. Most of these flags can also be set within an RE: A a ASCII Make \w, \W, \b, \B, \d, and \D match the corresponding ASCII character categories. Default when matching a bytestring. B b BESTMATCH Find the best fuzzy match (default is first). D DEBUG Print the parsed pattern. E e ENHANCEMATCH Attempt to improve the fit after finding the first fuzzy match. F f FULLCASE Use full case-folding when performing case-insensitive matching in Unicode. I i IGNORECASE Perform case-insensitive matching. L L LOCALE Make \w, \W, \b, \B, \d, and \D dependent on the current locale. (One byte per character only.) M m MULTILINE "^" matches the beginning of lines (after a newline) as well as the string. "$" matches the end of lines (before a newline) as well as the end of the string. P p POSIX Perform POSIX-standard matching (leftmost longest). R r REVERSE Searches backwards. S s DOTALL "." matches any character at all, including the newline. U u UNICODE Make \w, \W, \b, \B, \d, and \D dependent on the Unicode locale. Default when matching a Unicode string. V0 V0 VERSION0 Turn on the old legacy behaviour. V1 V1 VERSION1 Turn on the new enhanced behaviour. This flag includes the FULLCASE flag. W w WORD Make \b and \B work with default Unicode word breaks and make ".", "^" and "$" work with Unicode line breaks. X x VERBOSE Ignore whitespace and comments for nicer looking REs. This module also defines an exception 'error'. cache_allcompileDEFAULT_VERSIONescapefindallfinditer fullmatchmatchpurgesearchsplit splititersubsubfsubfnsubntemplateScannerAASCIIBZ BESTMATCHDDEBUGEZ ENHANCEMATCHSDOTALLFZFULLCASEI IGNORECASELLOCALEM MULTILINEPZPOSIXRREVERSETTEMPLATEUUNICODEZV0VERSION0ZV1VERSION1XVERBOSEWZWORDerrorRegex __version____doc__z2.5.91NFc Ks$t|||| d} | ||||||S)zqTry to apply the pattern at the start of the string, returning a match object, or None if no match was found.T)_compiler) patternstringflagsposendpospartial concurrenttimeout ignore_unusedkwargspatr?//tmp/pip-unpacked-wheel-iskm9a3s/regex/regex.pyrsc Ks$t|||| d} | ||||||S)zpTry to apply the pattern against all of the string, returning a match object, or None if no match was found.T)r3r) r4r5r6r7r8r9r:r;r<r=r>r?r?r@rsc Ks$t|||| d} | ||||||S)zvSearch through string looking for a match to the pattern, returning a match object, or None if no match was found.T)r3r ) r4r5r6r7r8r9r:r;r<r=r>r?r?r@r sc Ks&t||| | d} | |||||||S)atReturn the string obtained by replacing the leftmost (or rightmost with a reverse pattern) 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 a callable, it's passed the match object and must return a replacement string to be used.T)r3r ) r4replr5countr6r7r8r:r;r<r=r>r?r?r@r sc Ks&t||| | d} | |||||||S)arReturn the string obtained by replacing the leftmost (or rightmost with a reverse pattern) non-overlapping occurrences of the pattern in string by the replacement format. format can be either a string or a callable; if a string, it's treated as a format string; if a callable, it's passed the match object and must return a replacement string to be used.T)r3r) r4formatr5rBr6r7r8r:r;r<r=r>r?r?r@rsc Ks&t||| | d} | |||||||S)aReturn a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost (or rightmost with a reverse pattern) non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made. repl can be either a string or a callable; if a string, backslash escapes in it are processed; if a callable, it's passed the match object and must return a replacement string to be used.T)r3r) r4rAr5rBr6r7r8r:r;r<r=r>r?r?r@r"s c Ks&t||| | d} | |||||||S)aReturn a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost (or rightmost with a reverse pattern) non-overlapping occurrences of the pattern in the source string by the replacement format. number is the number of substitutions that were made. format can be either a string or a callable; if a string, it's treated as a format string; if a callable, it's passed the match object and must return a replacement string to be used.T)r3r) r4rCr5rBr6r7r8r:r;r<r=r>r?r?r@r.s c Ks t||||d}|||||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.T)r3r ) r4r5maxsplitr6r:r;r<r=r>r?r?r@r :sc Ks t||||d}|||||S)z8Return an iterator yielding the parts of a split string.T)r3r ) r4r5rDr6r:r;r<r=r>r?r?r@r Esc Ks$t|||| d} | ||||||S)a'Return a list of all matches in the string. The matches may be overlapped if overlapped is True. If one or more 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.T)r3r) r4r5r6r7r8 overlappedr:r;r<r=r>r?r?r@rKsc Ks&t||| | d} | |||||||S)zReturn an iterator over all matches in the string. The matches may be overlapped if overlapped is True. For each match, the iterator returns a match object. Empty matches are included in the result.T)r3r) r4r5r6r7r8rEr9r:r;r<r=r>r?r?r@rTscKst||||tS)zACompile a regular expression pattern, returning a pattern object.)r3 _cache_all)r4r6r<r=r?r?r@r]scCsttdS)z"Clear the regular expression cacheN)_cacheclear_locale_sensitiver?r?r?r@r asTcCs|dkr tS|adS)zSets whether to cache all patterns, even those are compiled explicitly. Passing None has no effect, but returns the current setting.N)rF)valuer?r?r@riscCst||tBdidS)z7Compile a template pattern, returning a pattern object.F)r3r&)r4r6r?r?r@rsscCst|tr|d}n|}g}|rx|D]`}|dkrD|rD||q(|tksT|rj|d||q(|dkr~|dq(||q(Wnbx`|D]X}|dkr|r||q|tkr||q|dkr|dq|d||qWd|}t|tr|d}|S)zEscape a string for use as a literal in a pattern. If special_only is True, escape only special characters, else escape all non-alphanumeric characters. If literal_spaces is True, don't escape spaces.zlatin-1 \z\000) isinstancebytesdecodeappend _METACHARSisspace_ALNUMjoinencode)r4Z special_onlyZliteral_spacespscrr?r?r@rws6                 )RLock)getpreferredencoding)*) _ALL_VERSIONS_ALL_ENCODINGS_FirstSetError_UnscopedFlagSet_check_group_features_compile_firstset_compile_replacement _flatten_code _fold_case_get_required_string_parse_pattern _shrink_cache)ALNUMInfoOPSourceFuzzyz()[]{}?*+|^$\.-#&~ic+ syddlmaWntk r$YnX|t@dkr6d}t||f}t|dsZ|t@dkrbt}nd}|ry|t||f}t |}t } |rxN|D]F\} } y| | t || fWqt k rtd| YqXqWt | } |t||| t|f} t| St k rYnXt|tr*t} n8t|tr|s>t8t9|!}"td|"t:||;|}#d||f}j<|}$|$dk rt=j>|$fg|#t=j?fg}#|#t=j@fg7}#x&jAD]\}%}&}'|#|%;|&|'7}#qWtB|#}#|Csy$tD|E|}(tB|(}(|(|#}#WntFk rYnXtGddjH7D})tI;|j|B|#jH|)|||||jJ }*t5ttKkr|tLtMtt ttKWdQRX|rˆjt@dkrd}t |}|t|||t|f} |*t| <|t |<|*S)z1Compiles a regular expression to a PatternObject.r2)rFTNzmissing named list: {!r}z5cannot process flags argument with a compiled patternz3first argument must be a string or compiled patternzunbalanced parenthesisz5VERSION0 and VERSION1 flags are mutually incompatiblez9ASCII, LOCALE and UNICODE flags are mutually incompatiblez,cannot use UNICODE flag with a bytes pattern)indentreversec3s|]}t|VqdS)N)rg).0v)infor?r@ Osz_compile..zunused keyword argument {!a}css|]\}}||fVqdS)Nr?)rrnrsr?r?r@ru|s)Nregexr ImportErrorrtyperIgetr_getpreferredencoding _named_argssetadd frozensetKeyErrorr.rCrGrOstrr(rPrPattern ValueError TypeError _regex_core_Source_InfoZ char_typeguess_encodingboolr6r,Z ignore_spacerirb global_flagsmsgr4r7Zat_endr_r)r*r`r$_FuzzyZ inline_localeZ fix_groupsdumpZoptimiseZpack_charactersrhlenZnamed_lists_useditemsnextiterrcrZ call_refs_OPZCALL_REFZENDSUCCESSZadditional_groupsrfZhas_simple_startrdZ get_firstsetradictZ group_index_regexZ group_count _MAXCACHE _cache_lockrj)+r4r6r<r=Zcache_itZ locale_keyZpattern_localeZargs_keyZ args_neededZ args_suppliedkrsZ pattern_keyrrZcaught_exceptionsourceparsedeversionrqZfuzzyZ req_offsetZ req_charsZ req_flagsZ named_listsZnamed_list_indexeskeyindexnameZ case_flagsvaluesrZ unused_kwargsZany_onecoderefgrouprevZfuzZfs_code index_groupZcompiled_patternr?)rtr@r3s                              r3c Cs|j|j|f}t|}|dk r$|Stttkr8tt|t}t |}|rXdd}ndd}g}g}xj|}|sxP|dkrt |||\} } | r|r| ||g}| | q| | qj| t |qjW|r| |||t|<|S)z Compiles a replacement template.NcSsddd|DS)NrNcss|]}t|VqdS)N)chr)rrrZr?r?r@ruszC_compile_replacement_helper..make_string..)rV) char_codesr?r?r@ make_stringsz0_compile_replacement_helper..make_stringcSst|S)N)rP)rr?r?r@rsrL)r4r6_replacement_cacherzr _MAXREPCACHErHrOrrrerRextendord) r4rrZcompiledZ is_unicoderrliteralchZis_grouprr?r?r@_compile_replacement_helpers<      rrNcCs tj|jfS)N)rrZ _pickled_data)r4r?r?r@_picklesr)r2NNFNNF)r2NNFNNF)r2NNFNNF)r2r2NNNNF)r2r2NNNNF)r2r2NNNNF)r2r2NNNNF)r2r2NNF)r2r2NNF)r2NNFNNF)r2NNFFNNF)r2F)T)r2)TF)Jr1__all__r0rrr r rrrr r rrrr rFrrrZregex._regex_corerZ regex._regexr threadingr\_RLocklocaler]r{r_r`rarbrcrdrerfrgrhrirjrkrUrlrrmrrnrrorr)rrrSrGrr|rrIrrr3rZ_patryrMatchr/copyregZ _copy_regrpickler?r?r?r@s               ,    8Z5