If you can make re.sub work for you... import re pat="B(?:D|LD|VD|OUL(?:EVARD)?)" input="BD, BLD, BVD, BOUL, BOULEVARD.".split() for i in input: print i, "::", re.sub(pat, "BD", i) BD, :: BD, BLD, :: BD, BVD, :: BD, BOUL, :: BD, BOULEVARD. :: BD. For more complex cases you can pass a function instead of the replacement string. --Darrell