Regex to Strip Special Characters
Posted
by Neil
on Stack Overflow
See other posts from Stack Overflow
or by Neil
Published on 2010-04-28T21:07:26Z
Indexed on
2010/04/28
21:17 UTC
Read the original article
Hit count: 449
I am trying to use regex.replace to strip out unwanted characters, but I need to account for spaces:
string asdf = "doésn't work?";
string regie = @"([{}\(\)\^$&._%#!@=<>:;,~`'\’ \*\?\/\+\|\[\\\\]|\]|\-)";
Response.Write(Regex.Replace(asdf,regie,"").Replace(" ","-"));
returns doésntwork instead of doésnt-work
Ideas?
Thanks!
© Stack Overflow or respective owner