[categories] [index] [all (553)] [latest]
import re
def strTr( text, dic ):
""" Replaces keys of dic with values of dic in text.
2005-02 by Emanuel Rumpf """
pat = "(%s)" % "|".join( map(re.escape, dic.keys()) )
return re.sub( pat, lambda m:dic[m.group()], text )