All Courses

What distinguishes from re.match?"

By, a month ago
  • Bookmark

What distinguishes the search() and match() functions in the Python re module?
1 Answer

The search() function in the Python re-module searches for the first occurrence of a pattern in a string, whereas the match() function searches for a pattern only at the beginning of the string. In other words, search() looks for the pattern anywhere in the string, while match() only looks for the pattern at the beginning of the string. Additionally, search() returns a match object if it finds a match, while match() returns a match object only if the pattern is found at the beginning of the string.

Your Answer


Live Masterclass on : "How Machine Get Trained in Machine Learning?"

Mar 30th (7:00 PM) 516 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More