Skip to main content

Python RegEx findall() Functions

It is used to search for “all” occurrences that match a given pattern. In contrast, search() module will only return the first occurrence that matches the specified pattern. findall() will iterate over all the lines of the file and will return all non-overlapping matches of pattern in a single step.

Return all non-overlapping matches of pattern in string, as a list of strings. The function returns all the findings as a list. The search happens from left to right. If no matches are found, an empty list is returned.


re.findall(pattern, string, flags=0)


  • pattern:It is used to find the string.
  • string: In which the pattern has to be found.
  • flags:It is optional.

Return Value: It returns a List object.


import re

str = "Hello! Welcome to Python Programming"
res = re.findall("to",str)

Output: ['to']

Submitted by devanshi.srivastava on July 16, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.