def clean_string(s): for c in sep[:-2]: # do not remove dashes ('-') s = s.replace(c, ' ') parts = s.split() result = ' '.join(p for p in parts if p != '') # now also remove dashes on the outer part of the string while result and result[0] in sep: result = result[1:] while result and result[-1] in sep: result = result[:-1] return result
def find_words(s): return _words_rexp.findall(s.replace('_', ' '))
def iter_words(s): return _words_rexp.finditer(s.replace('_', ' '))
def iter_words(s): return _words_rexp.finditer(s.replace("_", " "))
def find_words(s): return _words_rexp.findall(s.replace("_", " "))