Is it possible to uppercase the first character of each word using regex?
I\'m going to be using this in VB.net (SSIS)
Why not just use the inbuilt TextInfo.ToTitleCase() method already in the .NET Framework?
string capitalized = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase("this string should be capitalized!");
s/\b(\w+)\b/ucfirst($1)/ge
.NET has builtin support for this. See TextInfo.ToTitleCase for documentation.
My code contains some extension methods for C#. I assume VB.NET has those too, but I do not know VB.NET well enough to convert them myself.
public static class StringExtensions {
public static string ToTitleCase(this string value) {
return value.ToTitleCase(CultureInfo.InvariantCulture);
}
public static string ToTitleCase(this string value, CultureInfo culture) {
return value.ToTitleCase(culture.TextInfo);
}
public static string ToTitleCase(this string value, TextInfo textInfo) {
return textInfo.ToTitleCase(value);
}
}