def sanitize_word(s):
 s = re.sub('[^\\w-]+', '_', s)
 s = re.sub('__+', '_', s)
 return s.strip('_')

def sanitize_word ( s ) : s = re . sub ( '[^\\w-]+' , '_' , s ) s = re . sub ( '__+' , '_' , s ) return s . strip ( '_' )
remove non-alphanumerical characters from metric word .