K idZgdZdZ d&dZ d&dZ d&dZ d'd Z d'd Z d'd Z d'd Z d(d Z d(dZ d&dZ d)dZ d*dZdZdad+dZd,dZd-dZddlmZddlmZddlmZddlmZddlddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ddlm*Z+m,Z-m.Z/m0Z1m2Z3e4jja6e7dZ8tle_6iZ9eZ:iZ;iZdZ?d Z@d!ZAe@d"ddidZBeCeBZDeCeBjd"ZE[Bejd#ejd$eZGddlHZId%ZJeIjeDeJy).a/Support 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'. There are a few differences between the old (legacy) behaviour and the new (enhanced) behaviour, which are indicated by VERSION0 or VERSION1. 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. *+,++,?+ Possessive 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. {m,n}+ Possessive version of the above. {...} Fuzzy matching constraints. "\\" 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 are captured and can be retrieved or matched later in the string. (?flags-flags) VERSION1: Sets/clears the flags for the remainder of the group or pattern; VERSION0: Sets the flags for the entire pattern. (?:...) Non-capturing version of regular parentheses. (?>...) 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'. )9 cache_allcompileDEFAULT_VERSIONescapefindallfinditer fullmatchmatchpurgesearchsplit splititersubsubfsubfnsubntemplateScannerAASCIIB BESTMATCHDDEBUGE ENHANCEMATCHSDOTALLFFULLCASEI IGNORECASELLOCALEM MULTILINEPPOSIXRREVERSETTEMPLATEUUNICODEV0VERSION0V1VERSION1XVERBOSEWWORDerrorRegex __version____doc__ RegexFlagz 2025.11.3NFc  Lt|||| d} | j||||||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_unusedkwargspats Q/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/regex/_main.pyr r s/ 7E=&$ ?C 99VS&*gw GGc  Lt|||| d} | j||||||S)zpTry to apply the pattern against all of the string, returning a match object, or None if no match was found.T)r=rr>s rJrrs/ 7E=&$ ?C ==fj'7 KKrKc  Lt|||| d} | j||||||S)zvSearch through string looking for a match to the pattern, returning a match object, or None if no match was found.T)r=r r>s rJr r s/ 7E=&$ ?C ::fc6:w HHrKc Nt||| | d} | j|||||||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)r=r r?replr@countrArBrCrErFrGrHrIs rJrrs1 7E=&$ ?C 774VZ IIrKc Nt||| | d} | j|||||||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)r=r r?formatr@rQrArBrCrErFrGrHrIs rJrrs1 7E=&$ ?C 88FFE3 G LLrKc Nt||| | d} | j|||||||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)r=rrOs rJrr"s1 7E=&$ ?C 88D&%fj' JJrKc Nt||| | d} | j|||||||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)r=rrSs rJrr.s1 7E=&$ ?C 99VVUCW MMrKc Ht||||d}|j||||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)r=r r?r@maxsplitrArErFrGrHrIs rJr r :s+ 7E=&$ ?C 99VXz7 ;;rKc Ht||||d}|j||||S)z8Return an iterator yielding the parts of a split string.T)r=r rXs rJr r Es+ 7E=&$ ?C ==:w ??rKc  Lt|||| d} | j||||||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)r=r) r?r@rArBrC overlappedrErFrGrHrIs rJrrKs/ 7E=&$ ?C ;;vsFJ G LLrKc Nt||| | d} | j|||||||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)r=r) r?r@rArBrCr\rDrErFrGrHrIs rJrrTs6 7E=&$ ?C <<VZW  rKc 0|t}t|||||S)zACompile a regular expression pattern, returning a pattern object.) _cache_allr=)r?rArG cache_patternrHs rJrr]s " GUM6= IIrKcTtjtjy)z"Clear the regular expression cacheN)_cacheclear_locale_sensitiverKrJr r cs LLNrKTc|tS|ay)zSets whether to cache all patterns, even those are compiled explicitly. Passing None has no effect, but returns the current setting.N)r_)values rJrrks  }JrKc.t||tzdidS)z7Compile a template pattern, returning a pattern object.F)r=r+)r?rAs rJrrus GUX-ub% @@rKcLt|tr|jd}n|}g}|rm|D]g}|dk(r|r|j||tvs|j r#|jd|j|W|j|in\|D]W}|dk(r|r|j||t vr|j|6|jd|j|Ydj|}t|tr|jd}|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 \) isinstancebytesdecodeappend _METACHARSisspace_ALNUMjoinencode)r? special_onlyliteral_spacespscrs rJrrys '5! NN9 %  A ACxN jAIIK    ACxN f     A'5! HHY  HrK) _regex_core)_regex)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  )* ddlma|tzdk7rd}t ||f}t j |ds |tzdk7r t}nd})fd}|r~ |t ||f}t|)t} )r*)D]%\} } | j| t| f'|t| } |t ||| t|f} t | St#|t$rt&} nAt#|t(rt*} n*t#|t,r|r t/d|St1d tt2_|} d} t5|}t7||j8*| *_t=*j>t@z|_!tE|*} |jQstd ||jN*j>tRzxst}|dtTtVfvr t/d *j>tXzdt*tt&fvr t/d t#|t(r*j>t&zr t/d *j>tXzsCt#|t$r*xj>t&zc_n*xj>t*zc_t=*j>tZz}t#|t\}*j^t |<d} |ja||d|r+t|jJ|jL|jN|tzr|jcd||je*|}|jg*}ti|*j>\}}}i}dgtk*jlz}t)*jljoD]N\}}|\}}t|}|rt*fd|D} n|} |||<| ||<)j||fP|tq*||js|}!d||f}*jtj |}"|")tvjx|"fg|!ztvjzfgz}!|!tvj|fgz }!*j~D]\}#}$}%|!|#js|$|%z }!t|!}!|js, t*|j|}&t|&}&|&|!z}!td*jjoD}'tjr|*j>|z|!*j|'|||||*j }(tkt tk\r-t5tt tt tddd|rJ*j>tzdk(rd}t))|t ||)t|f} |(t | <)t<|(S#t$rY wxYw#t$rtdj| wxYw#t$rYrwxYw#tF$r*jH}Ynt$r }|}Yd}~nd}~wwxYw|r+t|jJ|jL|jNi#t$r }|}Yd}~d}~wwxYw#t$rYwxYw#1swY%xYw)z1Compiles a regular expression to a PatternObject.r;)rFTNcrytDchc]\}}| c}}z }|r.tt|}tdj |ycc}}w)Nzunused keyword argument {!a})setnextiter ValueErrorrT)kv unused_kwargsany_one args_neededrGrHs rJcomplain_unused_argsz&_compile..complain_unused_argss\  F [&ATQq&AA 4 ./G;BB7KL L 'Bs Azmissing 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)indentreversec36K|]}t|ywN)r).0rinfos rJ z_compile..YsBajq1Bsc3*K|] \}}||f ywrre)rnrs rJrz_compile..sC$!Q1vCs)Lregexr ImportErrorrtyperdgetr#_getpreferredencoding _named_argsradd frozensetKeyErrorr6rTrbrmstrr-rnrPatternr TypeErrorr|_Source_Info char_typeguess_encodingboolrAr3 ignore_spacerr global_flagsmsgr?rBat_endrr/r1rr)_Fuzzy inline_locale fix_groupsdumpoptimisepack_charactersrlennamed_lists_useditemsrr call_refs_OPCALL_REFENDSUCCESSadditional_groupsrhas_simple_startr get_firstsetrdict group_indexr} group_count _MAXCACHE _cache_lockr)+r?rArGrHcache_it locale_keypattern_localerargs_key args_suppliedrr pattern_keyrrcaught_exceptionsourceparsedeversionrfuzzy req_offset req_chars req_flags named_listsnamed_list_indexeskeyindexname case_flagsvaluesrcoderefgrouprevfuzfs_code index_groupcompiled_patternrrs+ `` @@rJr=r=s )  !w-)JZ.56>a2G.0M W u4H%h/K EM'JDAqJ%))1iq .B*CDJ ! "%m4M#DM5-~/K+& & '3  GU # GW % TU UMNN#2KL  !W%Fv'7'7@D"0D "&tzzG';">' "D gu C ..  S !C s#$t+{m; ckk_ D 11(sC  c3''(  D  " " $ 'f.A.A'.JKG#G,GT>D C$*:*:*@*@*BCCK~~gtzzG/CT  [2D)Y(8(8:  6{i  M &+/@) L M JJ A %!N , W uk >+ .{!, H s    L$J#$>$E$Ea$HIIJ   >  -,,L !  ! (,,.>.F.F""$ $! b ~   " M MsX +Y X+1Y AY3Z0&+[ [ XX$YY YYY>*Y>2Y99Y>0 [9[[ [[[#c\|j|j|f}tj|}||St tt k\rtj t|t}t|}|rd}nd}g}g} |j}|snq|dk(rQt|||\} } | r-|r|j||g}|j| n,|j| n|jt||r|j|||t|<|S)z Compiles a replacement template.c2djd|DS)Nrlc32K|]}t|ywr)chr)rrzs rJrzC_compile_replacement_helper..make_string..s6a3q66s)rt char_codess rJ make_stringz0_compile_replacement_helper..make_strings776:66 6rKct|Sr)rnrs rJrz0_compile_replacement_helper..make_strings $ $rKrk)r?rA_replacement_cacherr _MAXREPCACHErcrmrrrrpextendord) r?rrcompiled is_unicoderrliteralchis_grouprs rJ_compile_replacement_helperrs //7==( 2C!%%c*H ,.  "Hc*J X F 7 %HG  ZZ\  :367JOOHeOOK$89 G&u% NN3r7 #% * G,-&s OrKrlrMatchc:tj|jfSr)r}r _pickled_data)r?s rJ_picklers >>700 00rK)r;NNFNNF)r;r;NNNNF)r;r;NNF)r;NNFFNNF)r;FN)T)r;)TF)Lr9__all__r8r rr rrrrr r rrrr r_rrrrr|r} threadingr~_RLocklocalerrregex._regex_corerrrrrrrrrrrrrrsrrrrrrrrr:r/rrrqrbrrrrdrrr=r_patrrrrpr7copyreg _copy_regrpicklererKrJrs Xv  DI/4HHM/4LEJ/4ICG/4JFJ/4MDH/4 KGK/4 NJN <@D#@ IN/4MJO>CJ   A# P%@!!!! $$ , - -  h     _B2jAub%( t* TZZ^yw 1 '"rK