'Normalize a string and remove non-alphanumeric characters.'

def slugify(self, text):

    text = re.sub("[-'_\\s]", '_', text)
    text = re.sub('_+', '_', text).strip('_')
    pat = '([^,\\(]*)\\((.*?)\\)'
    text = re.sub(pat, '\\g<1>', text).strip()
    try:
        text = unicodedata.normalize('NFKD', text).encode('ascii', 'ignore')
        text = six.text_type(re.sub('[-\\s]+', '    ', text.decode('utf-8')))
    except UnicodeDecodeError:
        self._log.exception(u"Failing    to    normalize    '{0}'", text)
    return text
