Answers for "add spaces between words unity"

C#
1

add spaces between words unity

public string AddSpacesToSentence(string text)
{
    if (string.IsNullOrWhiteSpace(text))
      return "";
      
    StringBuilder newText = new StringBuilder(text.Length * 2);
    newText.Append(text[0]);
    for (int i = 1; i < text.Length; i++)
    {
      if (char.IsUpper(text[i]) && text[i - 1] != ' ')
        newText.Append(' ');
      newText.Append(text[i]);
    }
    return newText.ToString();
}
Posted by: Guest on May-03-2020

Code answers related to "add spaces between words unity"

C# Answers by Framework

Browse Popular Code Answers by Language