On Dec 9, 6:13 pm, charonzen <[EMAIL PROTECTED]> wrote: The following *may* come close to doing what your revised spec requires:
import re def ch_replace2(alist, text): for bigram in alist: pattern = r'\b' + bigram.replace('_', ' ') + r'\b' text = re.sub(pattern, bigram, text) return text Cheers, John -- http://mail.python.org/mailman/listinfo/python-list