Regex Flags
Flags modify matching behavior. Common ones: re.IGNORECASE, re.MULTILINE, re.DOTALL, re.VERBOSE.
Flags modify matching behavior. Common ones: re.IGNORECASE, re.MULTILINE, re.DOTALL, re.VERBOSE.
import re
text = "Hello
World"
# re.DOTALL makes . match newlines too
match = re.search(r"Hello.World", text, re.DOTALL)
print(match.group()) # Hello
World
# re.IGNORECASE
print(re.findall(r"hello", text, re.I)) # ["Hello"]
Use re.VERBOSE to write multi-line, commented patterns for complex regex.