import re f = open("exampletext.txt") text = f.read() f.close() pattern = r"T\w*" regex = re.compile(pattern) result = regex.findall(text) print(result)