findall(module is used to search for "alloccurrences that match given pattern in contrastsearch (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 single step the findall (function returns list containing all matches exampleprint list of all matchesimport re txt "the rain in spainx re findall("ai"txtprint(xoutput['ai'ai'for examplehere we have list of -mail addressesand we want all the -mail addresses to be fetched out from the listwe use the method re findall(in python it will find all the -mail addresses from the list the sub (functionthe sub(function replaces the matches with the text of your choicereplace every white-space character with the number import re txt "the rain in spainx re sub("\ "" "txtprint(xoutputthe rain in spain you can control the the count parameternumber of examplereplace the first occurrences replacements by specifying