Lines Matching full:pattern
21 the pattern and the strings being processed can contain null bytes and
56 (?(id/name)yes|no) Matches yes pattern if the group with id/name matched,
57 the (optional) no pattern otherwise.
88 match Match a regular expression pattern to the beginning of a string.
89 fullmatch Match a regular expression pattern to all of a string.
90 search Search a string for the presence of a pattern.
91 sub Substitute occurrences of a pattern found in a string.
93 split Split a string by the occurrences of a pattern.
94 findall Find all occurrences of a pattern in a string.
96 compile Compile a pattern into a Pattern object.
133 "error", "Pattern", "Match", "A", "I", "L", "M", "S", "X", "U",
153 DEBUG = _compiler.SRE_FLAG_DEBUG # dump pattern after compilation
163 def match(pattern, string, flags=0): argument
164 """Try to apply the pattern at the start of the string, returning
166 return _compile(pattern, flags).match(string)
168 def fullmatch(pattern, string, flags=0): argument
169 """Try to apply the pattern to all of the string, returning
171 return _compile(pattern, flags).fullmatch(string)
173 def search(pattern, string, flags=0): argument
174 """Scan through string looking for a match to the pattern, returning
176 return _compile(pattern, flags).search(string)
178 def sub(pattern, repl, string, count=0, flags=0): argument
180 non-overlapping occurrences of the pattern in string by the
185 return _compile(pattern, flags).sub(repl, string, count)
187 def subn(pattern, repl, string, count=0, flags=0): argument
190 non-overlapping occurrences of the pattern in the source
196 return _compile(pattern, flags).subn(repl, string, count)
198 def split(pattern, string, maxsplit=0, flags=0): argument
199 """Split the source string by the occurrences of the pattern,
201 capturing parentheses are used in pattern, then the text of all
202 groups in the pattern are also returned as part of the resulting
206 return _compile(pattern, flags).split(string, maxsplit)
208 def findall(pattern, string, flags=0): argument
211 If one or more capturing groups are present in the pattern, return
212 a list of groups; this will be a list of tuples if the pattern
216 return _compile(pattern, flags).findall(string)
218 def finditer(pattern, string, flags=0): argument
223 return _compile(pattern, flags).finditer(string)
225 def compile(pattern, flags=0): argument
226 "Compile a regular expression pattern, returning a Pattern object."
227 return _compile(pattern, flags)
234 def template(pattern, flags=0): argument
235 "Compile a template pattern, returning a Pattern object, deprecated"
244 return _compile(pattern, flags|T)
253 def escape(pattern): argument
257 if isinstance(pattern, str):
258 return pattern.translate(_special_chars_map)
260 pattern = str(pattern, 'latin1')
261 return pattern.translate(_special_chars_map).encode('latin1')
263 Pattern = type(_compiler.compile('', 0)) variable
272 def _compile(pattern, flags): argument
273 # internal: compile pattern
277 return _cache[type(pattern), pattern, flags]
280 if isinstance(pattern, Pattern):
283 "cannot process flags argument with a compiled pattern")
284 return pattern
285 if not _compiler.isstring(pattern):
286 raise TypeError("first argument must be string or compiled pattern")
294 p = _compiler.compile(pattern, flags)
302 _cache[type(pattern), pattern, flags] = p
306 def _compile_repl(repl, pattern): argument
307 # internal: compile replacement pattern
308 return _parser.parse_template(repl, pattern)
310 def _expand(pattern, match, template): argument
312 template = _parser.parse_template(template, pattern)
315 def _subx(pattern, template): argument
316 # internal: Pattern.sub/subn implementation helper
317 template = _compile_repl(template, pattern)
330 return _compile, (p.pattern, p.flags)
332 copyreg.pickle(Pattern, _pickle, _compile)
343 # combine phrases into a compound pattern