Basically, I want to count sets of specific characters in a string. In other words I need to count all Letters and Numbers, and nothing else. But I cant seem to find the right (regex) syntax. Here's what i have ...
public double AlphaNumericCount(string s)
{
double count = Regex.Matches(s, "[A-Z].[a-z].[0-9]").Count;
return count;
}
I've been looking around, but cant seem to find anything that allows more than one set of characters. Again, I'm not sure on the syntax maybe it should be "[A-Z]/[a-z]/[0-9]" or something. Anywho, go easy on me - its my first day using Regex.
Thanks.
Regular Expression Cheat Sheet
Expresso Regular Expression tool
[A-Z].[a-z].[0-9]
will match any capital letter ([A-Z]
), followed by any character (.
), followed by any lower case letter ([a-z]
), followed by any character (.
), followed by any number ([0-9]
).
What you want to match on any letter or number is [A-Za-z0-9]
.
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