Python RegEx – A RegEx, or Regular Expression, is basically a sequence of characters that forms or leads to a specific search pattern. RegEx is used to check whether a string contains the specified search pattern or not.
Python already has a built-in package called re, which is used to work with Regular Expressions.
Importing: import re
The re module offers a set of functions listed below:
- Search – It returns a Match object if there is a match anywhere in the string.
- Split – It returns a list where the string has been split at each match.
- Sub – It replaces one or many matches with the string.
- findall – It returns a list containing all matches.