All Courses

What distinguishes re.search from re.match?"

By Pp5344229@gmail.com, a month ago
  • Bookmark
0

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

Re.search
Re.match
Python
1 Answer
0
Goutamp777

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

Webinars

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