Is there any .Net library to remove all problematic characters of a string and only leave alphanumeric, hyphen and underscore (or similar subset) in an intelligent way? This is for using in URLs, file names, etc.
I’m looking for something similar to stringex which can do the following:
A simple prelude
“simple English”.to_url =>
“simple-english”“it’s nothing at all”.to_url =>
“its-nothing-at-all”“rock & roll”.to_url =>
“rock-and-roll”Let’s show off
“$12 worth of Ruby power”.to_url =>
“12-dollars-worth-of-ruby-power”“10% off if you act now”.to_url =>
“10-percent-off-if-you-act-now”You don’t even wanna trust Iconv for this next part
“kick it en Français”.to_url =>
“kick-it-en-francais”“rock it Español style”.to_url =>
“rock-it-espanol-style”“tell your readers 你好”.to_url =>
“tell-your-readers-ni-hao”
I couldn’t find any library that does it, like in Ruby, so I ended writing my own method. This is it in case anyone cares: