re.findall()

Iterates over a string to find a subset of characters that match a specified pattern. It will return a list of every match that occurs in a given string.

Syntax

Loading...

where <pattern> can include any of the following:

  • A string: Jane
  • A character class code: /w, /s , /d
  • A regex symbol: $, |, ^

There are optional arguments that include the following:

  • A starting index value (pos): 3
  • An index value to end the search (endpos): 40
  • Flags: IGNORECASE, VERBOSE, DOTALL

Example 1

Match all of the times in the string:

Loading...

Example 2

A regex to match all of the email addresses within a string:

Loading...
Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy