[英]Regular expression to check for special characters except space
I want to check for special characters in a string EXCEPT spaces and delete them. 我想检查字符串中除空格以外的特殊字符并删除它们。
Ex: input = "Oh Boy!!#$" output = "Oh Boy" 例如:输入=“哦,男孩!#$”输出=“哦,男孩”
Can someone help me with the regular expression to implement this in C# 有人可以帮我用正则表达式在C#中实现它吗
这是一种方法:
Console.WriteLine(Regex.Replace("Oh Boy!!#$", @"[^\w ]", ""));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.