re.MatchObject.start()
This method returns the first index of the substring matched by group.
Syntax: re.MatchObject.start([group])
Parameter:
- group: (optional) group defaults to zero (meaning the whole matched substring). Return -1 if group exists but did not contribute to the match.
Return: Index of start of the substring matched by group.
AttributeError: If a matching pattern is not found then it raise AttributeError.
Python Regex – re.MatchObject.start() and re.MatchObject.end() functions
In this article, we are going to see re.MatchObject.start() and re.MatchObject.end() regex methods.