<Extension()>
Public Function TurnIntoWords(Str As String, Optional Separator As String = " ") As String
Dim Res As New StringBuilder(If(Str.Length, Str(0), "")), Ch As Char
For Q As Integer = 1 To Str.Length - 2
Ch = Str(Q)
If _
Char.IsUpper(Ch) _
AndAlso (Char.IsLower(Str(Q - 1)) OrElse Char.IsLower(Str(Q + 1))) _
Then
Res.Append(Separator)
End If
Res.Append(Ch)
Next Q
If Str.Length Then Res.Append(Str(Str.Length - 1))
Return Res.ToString()
End Function
public static string TurnIntoWords(this string Str, string Separator = " ")
{
StringBuilder Res = new StringBuilder(Str.Length != 0 ? Str[0].ToString() : "");
char Ch = '\0';
for (int Q = 1; Q <= Str.Length - 2; Q++)
{
Ch = Str[Q];
if (char.IsUpper(Ch) && (char.IsLower(Str[Q - 1]) || char.IsLower(Str[Q + 1])))
Res.Append(Separator);
Res.Append(Ch);
}
if (Str.Length != 0)
Res.Append(Str[Str.Length - 1]);
return Res.ToString();
}
source
share