def parameterize(string, separator='-'):
    """
    Replace special characters in a string so that it may be used as part of a
    'pretty' URL.
    Example::
        >>> parameterize(u"Donald E. Knuth")
        'donald-e-knuth'
    """
    string = transliterate(string)
    # Turn unwanted chars into the separator
    string = re.sub(r"(?i)[^a-z0-9\-_]+", separator, string)
    if separator:
        re_sep = re.escape(separator)
        # No more than one of the separator in a row.
        string = re.sub(r'%s{2,}' % re_sep, separator, string)
        # Remove leading/trailing separator.
        string = re.sub(r"(?i)^%(sep)s|%(sep)s$" % {'sep': re_sep}, '', string)

    return string.lower()
def parameterize ( string , separator = '-' ) : string = transliterate ( string ) string = re . sub ( r"(?i)[^a-z0-9\-_]+" , separator , string ) if separator : re_sep = re . escape ( separator ) string = re . sub ( r'%s{2,}' % re_sep , separator , string ) string = re . sub ( r"(?i)^%(sep)s|%(sep)s$" % { 'sep' : re_sep } , '' , string ) return string . lower ( )
Replace special characters in a string so that it may be used as part of a
    'pretty' URL.
    Example::
        >>> parameterize(u"Donald E. Knuth")
        'donald-e-knuth'