![]() |
VOOZH | about |
In Python, re.compile() from the re module creates a regex object from a regular expression pattern. This object lets you perform operations like search(), match(), and findall(). In this article, we will understand about re.compile() method.
3
Table of Content
re.compile(pattern, flags=0)
pattern (str):r'\d+' (matches one or more digits).flags (optional):re.IGNORECASE or re.I: Ignore case sensitivity.re.MULTILINE or re.M: Allow ^ and $ to match start and end of lines.re.DOTALL or re.S: Allow . to match newline characters.re.VERBOSE or re.X: Allow adding comments and whitespace for better readability.In this code we are not using flags which is an optional parameter:
Found: 123-45-6789
In this code we are using flags (Modifiers that change the behavior of the regex.)
Hello