Regular expression is a python built-in module that provides the option to perform regular expressions matching operations.
Match Function
The match function, allows us to check for a match at the beginning of the string. Let’s see an example, to understand how this match function works:
We can clearly see that the first print only gives us a result while the second print gives a “None” output, this is because the match function will only search at the beginning of the string as mention above.
Search Function
The search function is similar to the match function, but it checks along the entire string. Let’s see the following example:
As I said above, this function search for the entire string a given substring. On the first print, it finds the string “key” at the end and on the second print, it doesn’t find the string “key” so it gives a “None” output.