import re text = "The quick brown fox jumps over the lazy dog" matches = re.findall("fox|dog", text) print(matches)