Reputation: 4364
I am looking for something rather specific, and I don't really know what to call it. Let me explain: I require a small class/struct that takes a string and gathers information about it. So I pass my string into the constructor and it "frisks" the string, gathering how many characters the string has, how many letters are in it, how many numbers, how many lower case letters, how many uppercase letters, how long it is, etc. I was about to develop this myself, but was wondering I it already existed within the .NET framework.
Thanks.
Upvotes: 0
Views: 96
Reputation: 14231
In addition to the System.String and System.Char classes to gather information, you can use classes in the System.Globalization namespace, such as StringInfo, TextInfo, CharUnicodeInfo and others.
Moreover, you can use the Character Classes in Regular Expressions. For example, Unicode Categories: diacritic marks, punctuation and others. Or Unicode Named Blocks: IsGreek, IsCyrillic and many others.
Upvotes: 1
Reputation: 25370
No, this doesn't exist. But it's simple enough to write yourself, you can do everything you require with a bit of LINQ and char extensions:
var count = str.Count();
var letters = str.Count(char.IsLetter);
var numbers = str.Count(char.IsDigit);
var lowers = str.Count(char.IsLower);
var uppers = str.Count(char.IsUpper);
//etc...
Upvotes: 5
Reputation: 802
Have a look at the Char structure.
It has lots of static functions like Char.IsDigit
, Char.IsNumber
, Char.IsLower
Upvotes: 1
Reputation: 14044
NO there is no such class exists in .NET Framework which gives you all the necessary details you are looking for. You need to create it yourself.
Just my assumption after looking at the details you are looking into the string you might be looking for Verifying Password Strength
Upvotes: 2