Remove non-alphanumerical characters excluding space

Posted by Cecco on Stack Overflow See other posts from Stack Overflow or by Cecco
Published on 2010-06-07T12:12:12Z Indexed on 2010/06/07 12:22 UTC
Read the original article Hit count: 251

Filed under:
|

I have this statement:

String cap = Regex.Replace(winCaption, @"[^\w\.@-]", ""); 

that transforms "Hello | World!?" to "HelloWorld".

But I want to preserve space character, for example: "Hello | World!?" to "Hello  World".

How can I do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex