The re.MULTILINE search modifier forces the ^ symbol to match at the beginning of each line of text (and not just the first), and the $ symbol to match at the end of each line of text (and not just the last one).
The re.MULTILINE search modifier takes no arguments.
In this example we start with the following text and search pattern:
pattern = r"^dog"
Note that the text includes a line break:
dogs and cats eat
By default, the regex search will only find a match at the beginning of the text (on the first line):
However, using the re.MULTILINE modifier will cause matches to be found at the beginning of each line: