regex.match(string[, pos[, endpos]])
If zero or more characters at the beginning of string match this regular expression, return a corresponding match object. Return None
if the string does not match the pattern; note that this is different from a zero-length match.
The optional pos and endpos parameters have the same meaning as for the search()
method.
>>> pattern = re.compile("o") >>> pattern.match("dog") # No match as "o" is not at the start of "dog". >>> pattern.match("dog", 1) # Match as "o" is the 2nd character of "dog". <_sre.SRE_Match object; span=(1, 2), match='o'>
If you want to locate a match anywhere in string, use search()
instead (see also search() vs. match()).
Please login to continue.