- findall() is a regular expresion function in python, that match the given pattern to the string and return the match pattern in the form of the list.
Syntax-
re.findall(pattern,string)
Example-
String is s="this is this buddy"
then re.findall("this",s) will return ["this","this"]
program-
#import the re module
import re
#take input of string and pattern for search
print("Enter string")
s=input()
print("Enter sunstring to be searched")
ss=input()
#fill all the match pattern in list
x=re.findall(ss,s)
print("After match :",x)
print("occurrence of match pattern :",len(x))
Enter string
This is the island
Enter sunstring to be searched
is
After match : ['is', 'is', 'is']
occurrence of match pattern : 3