If my input string is ~!@#$%^&*()_+{}:\"<>?
How do I get the count of each special character using Regex? For example:
Regex.Match
Regex is not the best way to do this. here is the Linq
based solution
string chars = "~!@#$%^&*()_+{}:\"<>?";
foreach (var item in chars.Where(x=> !char.IsLetterOrDigit(x)).GroupBy(x => x))
{
Console.WriteLine(string.Format("{0},{1}",item.Key,item.Count()));
}
I understand that you need to count each spl character count. Correct me If am mistaken.