• Home
  • Raw
  • Download

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
187 def match(pattern, string, flags=0): argument
188 """Try to apply the pattern at the start of the string, returning
190 return _compile(pattern, flags).match(string)
192 def fullmatch(pattern, string, flags=0): argument
193 """Try to apply the pattern to all of the string, returning
195 return _compile(pattern, flags).fullmatch(string)
197 def search(pattern, string, flags=0): argument
198 """Scan through string looking for a match to the pattern, returning
200 return _compile(pattern, flags).search(string)
202 def sub(pattern, repl, string, count=0, flags=0): argument
204 non-overlapping occurrences of the pattern in string by the
209 return _compile(pattern, flags).sub(repl, string, count)
211 def subn(pattern, repl, string, count=0, flags=0): argument
214 non-overlapping occurrences of the pattern in the source
220 return _compile(pattern, flags).subn(repl, string, count)
222 def split(pattern, string, maxsplit=0, flags=0): argument
223 """Split the source string by the occurrences of the pattern,
225 capturing parentheses are used in pattern, then the text of all
226 groups in the pattern are also returned as part of the resulting
230 return _compile(pattern, flags).split(string, maxsplit)
232 def findall(pattern, string, flags=0): argument
235 If one or more capturing groups are present in the pattern, return
236 a list of groups; this will be a list of tuples if the pattern
240 return _compile(pattern, flags).findall(string)
242 def finditer(pattern, string, flags=0): argument
247 return _compile(pattern, flags).finditer(string)
249 def compile(pattern, flags=0): argument
250 "Compile a regular expression pattern, returning a Pattern object."
251 return _compile(pattern, flags)
258 def template(pattern, flags=0): argument
259 "Compile a template pattern, returning a Pattern object"
260 return _compile(pattern, flags|T)
269 def escape(pattern): argument
273 if isinstance(pattern, str):
274 return pattern.translate(_special_chars_map)
276 pattern = str(pattern, 'latin1')
277 return pattern.translate(_special_chars_map).encode('latin1')
279 Pattern = type(sre_compile.compile('', 0)) variable
288 def _compile(pattern, flags): argument
289 # internal: compile pattern
293 return _cache[type(pattern), pattern, flags]
296 if isinstance(pattern, Pattern):
299 "cannot process flags argument with a compiled pattern")
300 return pattern
301 if not sre_compile.isstring(pattern):
302 raise TypeError("first argument must be string or compiled pattern")
303 p = sre_compile.compile(pattern, flags)
311 _cache[type(pattern), pattern, flags] = p
315 def _compile_repl(repl, pattern): argument
316 # internal: compile replacement pattern
317 return sre_parse.parse_template(repl, pattern)
319 def _expand(pattern, match, template): argument
321 template = sre_parse.parse_template(template, pattern)
324 def _subx(pattern, template): argument
325 # internal: Pattern.sub/subn implementation helper
326 template = _compile_repl(template, pattern)
339 return _compile, (p.pattern, p.flags)
341 copyreg.pickle(Pattern, _pickle, _compile)
352 # combine phrases into a compound pattern