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.
138 "error", "Pattern", "Match", "A", "I", "L", "M", "S", "X", "U",
155 DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation
188 def match(pattern, string, flags=0): argument
189 """Try to apply the pattern at the start of the string, returning
191 return _compile(pattern, flags).match(string)
193 def fullmatch(pattern, string, flags=0): argument
194 """Try to apply the pattern to all of the string, returning
196 return _compile(pattern, flags).fullmatch(string)
198 def search(pattern, string, flags=0): argument
199 """Scan through string looking for a match to the pattern, returning
201 return _compile(pattern, flags).search(string)
203 def sub(pattern, repl, string, count=0, flags=0): argument
205 non-overlapping occurrences of the pattern in string by the
210 return _compile(pattern, flags).sub(repl, string, count)
212 def subn(pattern, repl, string, count=0, flags=0): argument
215 non-overlapping occurrences of the pattern in the source
221 return _compile(pattern, flags).subn(repl, string, count)
223 def split(pattern, string, maxsplit=0, flags=0): argument
224 """Split the source string by the occurrences of the pattern,
226 capturing parentheses are used in pattern, then the text of all
227 groups in the pattern are also returned as part of the resulting
231 return _compile(pattern, flags).split(string, maxsplit)
233 def findall(pattern, string, flags=0): argument
236 If one or more capturing groups are present in the pattern, return
237 a list of groups; this will be a list of tuples if the pattern
241 return _compile(pattern, flags).findall(string)
243 def finditer(pattern, string, flags=0): argument
248 return _compile(pattern, flags).finditer(string)
250 def compile(pattern, flags=0): argument
251 "Compile a regular expression pattern, returning a Pattern object."
252 return _compile(pattern, flags)
259 def template(pattern, flags=0): argument
260 "Compile a template pattern, returning a Pattern object"
261 return _compile(pattern, flags|T)
270 def escape(pattern): argument
274 if isinstance(pattern, str):
275 return pattern.translate(_special_chars_map)
277 pattern = str(pattern, 'latin1')
278 return pattern.translate(_special_chars_map).encode('latin1')
280 Pattern = type(sre_compile.compile('', 0)) variable
289 def _compile(pattern, flags): argument
290 # internal: compile pattern
294 return _cache[type(pattern), pattern, flags]
297 if isinstance(pattern, Pattern):
300 "cannot process flags argument with a compiled pattern")
301 return pattern
302 if not sre_compile.isstring(pattern):
303 raise TypeError("first argument must be string or compiled pattern")
304 p = sre_compile.compile(pattern, flags)
312 _cache[type(pattern), pattern, flags] = p
316 def _compile_repl(repl, pattern): argument
317 # internal: compile replacement pattern
318 return sre_parse.parse_template(repl, pattern)
320 def _expand(pattern, match, template): argument
322 template = sre_parse.parse_template(template, pattern)
325 def _subx(pattern, template): argument
326 # internal: Pattern.sub/subn implementation helper
327 template = _compile_repl(template, pattern)
340 return _compile, (p.pattern, p.flags)
342 copyreg.pickle(Pattern, _pickle, _compile)
353 # combine phrases into a compound pattern