I have a string that I converted to a TextInfo.ToTitleCase and removed the underscores and joined the string together. Now I need to change the first and only the first charact
The following code works with acronyms as well. If it is the first word it converts the acronym to lower case (e.g., VATReturn
to vatReturn
), and otherwise leaves it as it is (e.g., ExcludedVAT
to excludedVAT
).
name = Regex.Replace(name, @"([A-Z])([A-Z]+|[a-z0-9_]+)($|[A-Z]\w*)",
m =>
{
return m.Groups[1].Value.ToLower() + m.Groups[2].Value.ToLower() + m.Groups[3].Value;
});