def _replace(reps):
 if (not reps):
  return (lambda x: x)
 D = (lambda match: reps[match.group(0)])
 pattern = _re.compile('|'.join([_re.escape(k) for (k, v) in reps.items()]), _re.M)
 return (lambda string: pattern.sub(D, string))

def _replace ( reps ) : if ( not reps ) : return ( lambda x : x ) D = ( lambda match : reps [ match . group ( 0 ) ] ) pattern = _re . compile ( '|' . join ( [ _re . escape ( k ) for ( k , v ) in reps . items ( ) ] ) , _re . M ) return ( lambda string : pattern . sub ( D , string ) )
return a function that can make the replacements .