What is the best way to create acronym from upper letters in C#?
Example:
Alfa_BetaGameDelta_Epsilon
Expected result:
ABGDE
My solution works, but it's not nice
var classNameAbbreviationRegex = new Regex("[A-Z]+", RegexOptions.Compiled);
var matches = classNameAbbreviationRegex.Matches(enumTypeName);
var letters = new string[matches.Count];
for (var i = 0; i < matches.Count; i++)
{
letters[i] = matches[i].Value;
}
var abbreviation = string.Join(string.Empty, letters);
string.Join("", s.Where(char.IsUpper));
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