def fmt_subst ( regex , subst ) : return lambda text : re . sub ( regex , subst , text ) if text else text
replace function python regex
Replace regex with string .
def fmt_subst(regex, subst):
    """Replace regex with string."""
    return lambda text: re.sub(regex, subst, text) if text else text