Thanks for all your replies. I guess I've always used .*? as sort of an idiom for a non-greedy match, but I guess it only works if I specify the end point (which I didn't in the above case). e.g. re.search(r'exit: (.*?)$', a) Thanks for pointing that out! David