Python (Scripting) - Find all matching expression using re.findall
by
Jeremy Canfield |
Updated: November 20 2025
| Python (Scripting) articles
There are several built in modules that are part of the Python Standard Library included with your Python installation, such as os (Operating System) and re (Regular Expression) and sys (System).
There are a few Python modules that can be used to determine if a string or integer does or does not contain a matching expression.
- find - returns the first matching patterns anywhere in a string or integer
- re.findall (this article) - returns a list containing all of the matching patterns anywhere in a string or integer
- re.match - evaluates to true if there is a single match of a pattern at the beginning of a string or integer
- re.search - evaluates to true if there is a single match of a pattern anywhere in a string or integer
re.findall returns a list containing all of the matching patterns anywhere in a string or integer. If there are no matches of the pattern in the string or integer, an empty list will be returned.
In this example, the matches list should contain two values, Hello and Hello.
#!/usr/bin/python
import re
foo = "Hello once and Hello again"
matches = re.findall('.*Hello.*', foo, re.IGNORECASE)
print(f"matches = {matches}")
Did you find this article helpful?
If so, consider buying me a coffee over at 