What's the fastest way to convert a string of text into a url-safe variable?

Posted by ensnare on Stack Overflow See other posts from Stack Overflow or by ensnare
Published on 2010-04-03T16:53:30Z Indexed on 2010/04/03 17:03 UTC
Read the original article Hit count: 258

I'd like to convert a string of text, e.g., "User Name" into something which I can turn into part of a url, e.g., "User-Name." What's the fastest way to do a string replacement ("-" for " ") as well as make sure that characters are only [a-zA-Z0-9]?

© Stack Overflow or respective owner

Related posts about python

Related posts about string