3 from sre_constants import error as error
4 from typing import Any, AnyStr, Callable, Iterator, Union, overload
6 # ----- re variables and constants -----
7 if sys.version_info >= (3, 7):
8 from typing import Match as Match, Pattern as Pattern
10 from typing import Match, Pattern
12 class RegexFlag(enum.IntFlag):
32 ASCII = RegexFlag.ASCII
33 DEBUG = RegexFlag.DEBUG
35 IGNORECASE = RegexFlag.IGNORECASE
37 LOCALE = RegexFlag.LOCALE
39 MULTILINE = RegexFlag.MULTILINE
41 DOTALL = RegexFlag.DOTALL
43 VERBOSE = RegexFlag.VERBOSE
45 UNICODE = RegexFlag.UNICODE
47 TEMPLATE = RegexFlag.TEMPLATE
48 _FlagsType = Union[int, RegexFlag]
50 if sys.version_info < (3, 7):
55 def compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]: ...
57 def compile(pattern: Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ...
59 def search(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
61 def search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
63 def match(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
65 def match(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
69 def fullmatch(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
71 def fullmatch(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr] | None: ...
73 def split(pattern: AnyStr, string: AnyStr, maxsplit: int = ..., flags: _FlagsType = ...) -> list[AnyStr | Any]: ...
75 def split(pattern: Pattern[AnyStr], string: AnyStr, maxsplit: int = ..., flags: _FlagsType = ...) -> list[AnyStr | Any]: ...
77 def findall(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> list[Any]: ...
79 def findall(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> list[Any]: ...
81 # Return an iterator yielding match objects over all non-overlapping matches
82 # for the RE pattern in string. The string is scanned left-to-right, and
83 # matches are returned in the order found. Empty matches are included in the
84 # result unless they touch the beginning of another match.
86 def finditer(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Iterator[Match[AnyStr]]: ...
88 def finditer(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Iterator[Match[AnyStr]]: ...
90 def sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> AnyStr: ...
93 pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ...
96 def sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> AnyStr: ...
99 pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ...
102 def subn(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> tuple[AnyStr, int]: ...
105 pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ...
106 ) -> tuple[AnyStr, int]: ...
109 pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ..., flags: _FlagsType = ...
110 ) -> tuple[AnyStr, int]: ...
113 pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: _FlagsType = ...
114 ) -> tuple[AnyStr, int]: ...
115 def escape(pattern: AnyStr) -> AnyStr: ...
116 def purge() -> None: ...
117 def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ...