标签: c# .net regex
我想检查字符串EXCEPT空格中的特殊字符并删除它们。
Ex:input =“Oh Boy !!#$”output =“Oh Boy”
有人可以帮助我使用正则表达式在C#中实现它吗
答案 0 :(得分:5)
这是一种方式:
Console.WriteLine(Regex.Replace("Oh Boy!!#$", @"[^\w ]", ""));