开发者

Regular expression to check for special characters except space

开发者 https://www.devze.com 2023-01-22 03:04 出处:网络
I want to check for special characters in a string EXCEPT spaces and delete them. Ex: input = \"Oh Boy!!#$\" output = \"Oh Boy\"

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 w开发者_如何学Pythonith the regular expression to implement this in C#


This is one way:

Console.WriteLine(Regex.Replace("Oh Boy!!#$", @"[^\w ]", ""));
0

精彩评论

暂无评论...
验证码 换一张
取 消