just add a space to your character set, [^ \ w. @ -]
var winCaption = "Hello | World!?";
String cap = Regex.Replace(winCaption, @"[^\w\.@\- ]", "");
Please note that you need to avoid the "dash" (-) character, as it is usually used to indicate a range of characters (for example, [A-Za-z0-9])
source
share