Summercool: > to add to the test cases, the regular expression must be able to grep > snow tire and regular tire I presume there only the second tire has to be found. This is my first try: text = """ tire word tire word word retire word word tired word snowbird tire word tired on a snow day word snow tire and regular tire word word snow tire word word snow tire word word some snowtires word """ import re def finder(text): patt = re.compile( r"\b (\w*) \s* (tire)", re.VERBOSE) for mo in patt.finditer(text): if not mo.group(1).endswith("snow"): yield mo.start(2) for end in finder(text): print end The (lazy) output is the starting point of the "tire" that match: 1 11 28 43 63 73 120 Bye, bearophile