How to Get All Matches in Python


In this example we will show how to get all matches using the findall() function in Python.

Source Code

import re
# imported the re module, you can start using regular expressions

str1 = 'I love Python'

r = re.findall('o', str1)

print(r)

Output:

['o', 'o']
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments