Preprocess string to transform all diacritics and remove other special characters than appropriate
    
    :param string:
    :return:
368
def preprocess(string):
    
    string = unicode(string, encoding="utf-8")
    # convert diacritics to simpler forms
    string = regex1.sub(lambda x: accents[x.group()], string)
    # remove all rest of the unwanted characters
    return regex2.sub('', string).encode('utf-8')
311686
def remove_non_ascii(input_string):
    
    no_ascii = "".join(i for i in input_string if ord(i) < 128)
    return no_ascii
920706
def locale_escape(string, errors='replace'):
    '''
    
    '''
    encoding = locale.getpreferredencoding()
    string = string.encode(encoding, errors).decode('utf8')
    return string
1268664
def _normalize(self, string):
		'''  '''

		string = super(VerbixDe, self)._normalize(string)
		string = string.replace('sie; Sie', 'sie')
		string = string.strip()
		return string
979577
def cleanup_formatted_string(cls, formatted_string):
        
        # Remove whitespace
        result = formatted_string.replace(' ', '')
        # Remove any static token parentheses
        result = re.sub(settings.REGEX_PARENTHESIS, '', result)
        # Remove any multiple separator characters
        multi_character_matches = re.finditer('[%s]{2,}' % settings.SEPARATORS, result)
        for multi_character_match in sorted(multi_character_matches, key=lambda x: len(x.group()), reverse=True):
            match = multi_character_match.group()
            most_common_separator = Counter(list(multi_character_match.group())).most_common(1)[0][0]
            result = result.replace(match, most_common_separator)
        # Remove trailing or preceding non letter characters
        result = re.sub(settings.REGEX_ADJACENT_UNDERSCORE, '', result)
        #  not sure what this one was...but certainly not it.
        result = re.sub(settings.REGEX_SINGLE_PARENTHESIS, '', result)
        return result
927830
def string_to_identifier(s, white_space_becomes='_'):
    
    import re
    s = s.lower()
    s = re.sub(r"\s+", white_space_becomes, s) # replace whitespace with underscores
    s = re.sub(r"-", "_", s) # replace hyphens with underscores
    s = re.sub(r"[^A-Za-z0-9_]", "", s) # remove everything that's not a character, a digit or a _
    return s
1250413
public static function sanitize_string($string)
    {
        $string = self::remove_accents($string);
        $string = strtolower($string);
        $string = preg_replace('/[^a-zA-Z 0-9]+/', '', $string);
        $string = self::strip_space($string);

        return $string;
    }
457711
def clean_str(string):
    
    string = re.sub(r"[^A-Za-z0-9(),!?\'\`]", " ", string)
    string = re.sub(r"\'s", " \'s", string)
    string = re.sub(r"\'ve", " \'ve", string)
    string = re.sub(r"n\'t", " n\'t", string)
    string = re.sub(r"\'re", " \'re", string)
    string = re.sub(r"\'d", " \'d", string)
    string = re.sub(r"\'ll", " \'ll", string)
    string = re.sub(r",", " , ", string)
    string = re.sub(r"!", " ! ", string)
    string = re.sub(r"\(", r" \( ", string)
    string = re.sub(r"\)", r" \) ", string)
    string = re.sub(r"\?", r" \? ", string)
    string = re.sub(r"\s{2,}", " ", string)
    return string.strip().lower()
152451
def slugify(string, repchar='_'):
    
    slug_regex = re.compile(r'(^[{0}._-]+|[^a-z-A-Z0-9_.-]+|[{0}._-]+$)'.format(repchar))
    strip_regex = re.compile(r'[{0}._-]+'.format(repchar))

    transformations = [
        lambda x: slug_regex.sub(repchar, x),
        lambda x: strip_regex.sub(repchar, x),
        lambda x: x.strip(repchar),
        lambda x: x.lower(),
    ]
    result = string
    for process in transformations:
        result = process(result)

    return result
1065886
def strip_non_ascii(string):
    ''' '''
    if type(string) == datetime:
        return str(string)
    stripped = (c for c in string if 0 < ord(c) < 127)
    return ''.join(stripped)
762305
def preprocess(str)
      str.gsub!(/late/i, '')
      str.gsub!(/early/i, '')
      str.strip!
      str.gsub!(/\s+/, ' ')
      str.gsub!('0s', 'x') if str.match(/^[1-9]+0s$/)
      str.gsub!('-', 'x') if str.match(/^[1-9]+\-+$/)
      str
    end
1374242
def _strip_punctuation(s):
    
    if type(s) is str and not PYTHON_3:    # Bytestring (default in Python 2.x).
        return s.translate(string.maketrans("",""), string.punctuation)
    else:                 # Unicode string (default in Python 3.x).
        translate_table = dict((ord(char), u'') for char in u'!"#%\'()*+,-./:;<=>?@[\]^_`{|}~')
        return s.translate(translate_table)
829064
def unescape_all(string):
    """"""
    def escape_single(matchobj):
        return _unicode_for_entity_with_name(matchobj.group(1))
    return entities.sub(escape_single, string)
863547
def preprocess(content):
    

    if six.PY2:
        if not isinstance(content, unicode):
            if isinstance(content, str):
                _content = unicode(content, encoding=sys.stdin.encoding)
            elif isinstance(content, int):
                _content = unicode(content)
        else:
            _content = content
        assert isinstance(_content, unicode)

    elif six.PY3:
        _content = str(content)

    _content = re.sub(r'\r|\t|\n', ' ', _content)
    return _content
385672
def normalize(string: Text) -> Text:
    

    string = string.lower()
    string = unidecode(string)
    string = RE_WHITESPACES.sub(' ', string).strip()

    return string
624315
def _ensure_unicode_string(string):
        
        if not isinstance(string, six.text_type):
            string = string.decode('utf-8')
        return string
567095
def remove_accent_string(string):
    
    return utils.join([add_accent_char(c, Accent.NONE) for c in string])