If my input string is ~!@#$%^&*()_+{}:\"<>?
~!@#$%^&*()_+{}:\"<>?
How do I get the count of each special character using Regex? For example:
Regex.Match
If you want to follow other approach then you can use.
string str = "@123:*&^789'!@#$*()_+="; int count = 0; foreach (char c in str) { if (!char.IsLetterOrDigit(c.ToString(),0)) { count++; } } MessageBox.Show(count.ToString());