(s)
return s.strip('_')
Remove non-alphanumerical characters from metric word.
    And trim excessive underscores.
Remove non-alphanumerical characters from metric word.
    And trim excessive underscores.
Remove non - alphanumerical characters from metric word . And trim excessive underscores .
def sanitize_word(s):
    """Remove non-alphanumerical characters from metric word.
    And trim excessive underscores.
    """
    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 ( '_' )