re.Match.group()
re.Match.group() is a Python method in the Regex Module category. Returns one or more subgroups of the match. Group 0 is the entire match. The syntax is Match.group([group1, ...]). Parameters: group — optional group numbers/names. Returns: String or tuple of strings. A typical example: m = re.search(r"(\w+)\s(\w+)", "hello world")
m.group(0) # "hello world"
m.group(1) # "hello"
m.group(2) # "world". A close sibling is re.search(), which scans through the string looking for a match to the regex pattern. Returns the first match or None. A close sibling is re.match(), which checks for a match only at the beginning of the string. A close sibling is re.fullmatch(), which checks if the entire string matches the regex pattern. A close sibling is re.findall(), which returns all non-overlapping matches as a list of strings or tuples. More about this category: Regular expression operations — search, match, findall, sub, split.