I would like to replace all special characters in a string with a comma (,)
.
For Example:
Hello@Hello&Hello(Hello)
the output -
Hello,Hello,Hello,Hello,
(I don't known how to use regexp in C#)
Can i do this work using regexp in C#?
C# includes escaping character \ (backslash) before these special characters to include in a string. Use backslash \ before double quotes and some special characters such as \,\n,\r,\t, etc. to include it in a string.
Yes, you can use regular expressions
in C#.
Using regular expressions with C#
:
using System.Text.RegularExpressions; string your_String = "Hello@Hello&Hello(Hello)"; string my_String = Regex.Replace(your_String, @"[^0-9a-zA-Z]+", ",");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With