Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
remove special char
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { string str = "$c!sh$arp&st%ar"; Console.WriteLine(RemoveSpecialChars(str)); } } public static string RemoveSpecialChars(string str) { // Create a string array and add the special characters you want to remove string[] chars = new string[] { ",", ".", "/", "!", "@", "#", "$", "%", "^", "&", "*", "'", "\"", ";", "_", "(", ")", ":", "|", "[", "]" }; //Iterate the number of times based on the String array length. for (int i = 0; i < chars.Length; i++) { if (str.Contains(chars[i])) { str = str.Replace(chars[i], ""); } } return str; } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Lotto unieke getallen
Informashin prsonely
testing endpoint
pyramidalt
Fórum ➡ Aggregating 2 compatible dictionaries, using LINQ ♦
otro
Reverse And Shift Char in String
mysrc.tcl
decimal to multiple binary
ew
stackse - search stackoverflow differently
Please log in to post a comment.