Python regex `match` vs. `search` functions

Difference between Python regex match() and search() function!

Python Matching Versus Searching #

We have learned so far that Python offers two different primitive operations:

  • match
  • search

So, how they are different to each other?

Note that match checks for a match only at the beginning of a string, while search checks for a match anywhere in the string!

Example 1 #

Let’s try to find the word Python:

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy