I have a file similar to this:
RANDOMTEXTSAMPLE*
$SAMPLERANDOMTEXT
RANDOMSAMPLE*TEXT
I'm trying to extract and put into a list all instances of "sample" that have * at the end.
I tried with something like this:
import re
with open('file1.txt') as myfile:
content = myfile.read()
text = re.search(r'[0-9A-Z]{7}\*', content)
with open("file2.txt", "w") as myfile2:
myfile2.write(text)
However I would only get me the first result it found.
Any recommendations on how can I get all the instances of sample that end with * in a list, without adding the * to the list will be appreciated.
Thanks
EDIT: small corrections