January 2019
Beginner
318 pages
8h 23m
English
The match() function is a function of the re module. This function will match the specified re pattern with the string. If the match is found, a match object will be returned. A match object will contain the information about the match. If a match is not found, we will get the result as None. The match object has two methods:
The syntax for this function is as follows:
re.match(pattern, string)
Now, we are going see an example of re.match(). Create a re_match.py script and write the following content in it:
import restr_line = "This is python tutorial. Do you enjoy learning python ?"obj = re.match(r'(.*) enjoy (.*?) .*', str_line)
Read now
Unlock full access