LearnFrenzy
Sign in Take a free test

Regular Expressions · Regular Expressions MCQ · Question 1

match() versus search() Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

What is the difference between re.match() and re.search()?

  • A match looks only at the start of the string; search scans the whole string Correct
  • B match returns a list; search returns a string
  • C They are identical
  • D search looks only at the end of the string
Correct Answer: Option A

re.match(r"\d", "a1") is None, while re.search finds the 1.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links