I want to extract all occurrences of a pattern in Python. Here is what i have done
import re
string="Any information <p>sent to the server as clear text</p>, may be stolen and used later for <p>identity theft</p> or user impersonation. In addition, several privacy regulations state that sensitive information such as user<p> credentials will always be sent encrypted </p> to the web site."
regex='<p>.*</p>' # obviously it matches starting <p> to the last </p>
if re.findall(regex, String):
print(re.findall(regex, string))
else:
print('no match found')
I want to extract all the occurance of paragraph tags. I mean the output should be a list which looks like this
['<p>sent to the server as clear text</p>', '<p>identity theft</p>', '<p> credentials will always be sent encrypted </p>']
I've found few similar questions but not serving the purpose Find all occurrences of a substring in Python
Finding multiple occurrences of a string within a string in Python