def sanitize(string, ignore_characters=None):
 if (string is None):
  return
 ignore_characters = (ignore_characters or set())
 characters = ({'-', ':', '(', ')', '.'} - ignore_characters)
 if characters:
  string = re.sub(('[%s]' % re.escape(''.join(characters))), ' ', string)
 characters = ({"'"} - ignore_characters)
 if characters:
  string = re.sub(('[%s]' % re.escape(''.join(characters))), '', string)
 string = re.sub('\\s+', ' ', string)
 return string.strip().lower()

def sanitize ( string , ignore_characters = None ) : if ( string is None ) : return ignore_characters = ( ignore_characters or set ( ) ) characters = ( { '-' , ':' , '(' , ')' , '.' } - ignore_characters ) if characters : string = re . sub ( ( '[%s]' % re . escape ( '' . join ( characters ) ) ) , ' ' , string ) characters = ( { "'" } - ignore_characters ) if characters : string = re . sub ( ( '[%s]' % re . escape ( '' . join ( characters ) ) ) , '' , string ) string = re . sub ( '\\s+' , ' ' , string ) return string . strip ( ) . lower ( )
sanitize a string to strip special characters .