Remove all problematic characters in an intelligent way in C#
Posted
by J. Pablo Fernández
on Stack Overflow
See other posts from Stack Overflow
or by J. Pablo Fernández
Published on 2010-01-10T17:02:56Z
Indexed on
2010/05/22
13:01 UTC
Read the original article
Hit count: 278
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"
© Stack Overflow or respective owner