If my input string is ~!@#$%^&*()_+{}:\"<>?
How do I get the count of each special character using Regex? For example:
Regex.Match
It's been a while and I needed a similar answer for handling password validation. Pretty much what VITA said, but here was my specific take for others needing it for the same thing:
var pwdSpecialCharacterCount = Regex.Matches(item, "[~!@#$%^&*()_+{}:\"<>?]").Count;
var pwdMinNumericalCharacters = Regex.Matches(item, "[0-9]").Count;
var pwdMinUpperCaseCharacters = Regex.Matches(item, "[A-Z]").Count;
var pwdMinLowerCaseCharacters = Regex.Matches(item, "[a-z]").Count;