Introduction:
The 're' package provides several methods to actually perform queries on an input string.
Methods:
re. match(pattern, string): Search the regular expression pattern and return the first occurrence. [Checks for a match only at the beginning of the string.] (If a match is found in the first line, it returns the match object, else, returns null.)
re. search(pattern, string): Search the regular expression pattern and return the first occurrence. [Checks all lines of the input string.]
re. findall(pattern, string): search for all occurrences that match a given pattern.
Reference:
https://www.guru99.com/python-regular-expressions-complete-tutorial.html
网友评论