Home | History | Annotate | Download | only in python2.7

Lines Matching refs: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.
78 match Match a regular expression pattern to the beginning of a string.
79 search Search a string for the presence of a pattern.
80 sub Substitute occurrences of a pattern found in a string.
82 split Split a string by the occurrences of a pattern.
83 findall Find all occurrences of a pattern in a string.
85 compile Compile a pattern into a RegexObject.
126 DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation
134 def match(pattern, string, flags=0):
135 """Try to apply the pattern at the start of the string, returning
137 return _compile(pattern, flags).match(string)
139 def search(pattern, string, flags=0):
140 """Scan through string looking for a match to the pattern, returning
142 return _compile(pattern, flags).search(string)
144 def sub(pattern, repl, string, count=0, flags=0):
146 non-overlapping occurrences of the pattern in string by the
151 return _compile(pattern, flags).sub(repl, string, count)
153 def subn(pattern, repl, string, count=0, flags=0):
156 non-overlapping occurrences of the pattern in the source
162 return _compile(pattern, flags).subn(repl, string, count)
164 def split(pattern, string, maxsplit=0, flags=0):
165 """Split the source string by the occurrences of the pattern,
167 return _compile(pattern, flags).split(string, maxsplit)
169 def findall(pattern, string, flags=0):
172 If one or more groups are present in the pattern, return a
173 list of groups; this will be a list of tuples if the pattern
177 return _compile(pattern, flags).findall(string)
181 def finditer(pattern, string, flags=0):
186 return _compile(pattern, flags).finditer(string)
188 def compile(pattern, flags=0):
189 "Compile a regular expression pattern, returning a pattern object."
190 return _compile(pattern, flags)
197 def template(pattern, flags=0):
198 "Compile a template pattern, returning a pattern object"
199 return _compile(pattern, flags|T)
204 def escape(pattern):
205 "Escape all non-alphanumeric characters in pattern."
206 s = list(pattern)
208 for i, c in enumerate(pattern):
214 return pattern[:0].join(s)
227 # internal: compile pattern
232 pattern, flags = key
233 if isinstance(pattern, _pattern_type):
235 raise ValueError('Cannot process flags argument with a compiled pattern')
236 return pattern
237 if not sre_compile.isstring(pattern):
238 raise TypeError, "first argument must be string or compiled pattern"
240 p = sre_compile.compile(pattern, flags)
249 # internal: compile replacement pattern
253 repl, pattern = key
255 p = sre_parse.parse_template(repl, pattern)
263 def _expand(pattern, match, template):
265 template = sre_parse.parse_template(template, pattern)
268 def _subx(pattern, template):
269 # internal: pattern.sub/subn implementation helper
270 template = _compile_repl(template, pattern)
283 return _compile, (p.pattern, p.flags)
294 # combine phrases into a compound pattern
296 s = sre_parse.Pattern()