def dashrepl(matchobj):
if matchobj.group(0) == '-': return ' '
else: return '-'
re.sub('-{1,2}', dashrepl, 'pro----gram-files')
re.sub(r'sANDs', ' & ', 'Baked Beans And Spam', flags=re.IGNORECASE)
def dashrepl(matchobj):
if matchobj.group(0) == '-': return ' '
else: return '-'
re.sub('-{1,2}', dashrepl, 'pro----gram-files')
re.sub(r'sANDs', ' & ', 'Baked Beans And Spam', flags=re.IGNORECASE)