re.search()
re.search() is a Python function in the Regex Module category. Scans through the string looking for a match to the regex pattern. Returns the first match or None. The syntax is re.search(pattern, string, flags=0). Parameters: pattern, string — regex and input. Returns: Match object or None. A typical example: m = re.search(r"\\d+", "abc123def")
m.group() # "123"
m.start() # 3. 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. A close sibling is re.finditer(), which returns an iterator yielding Match objects for all non-overlapping matches. More about this category: Regular expression operations — search, match, findall, sub, split. For a broader walkthrough, read the Regex Module guide.