Utils/StringUtils.cs
using System.Text;

namespace Sandbox.Utils;

public static class StringUtils
{
	public static string AddSpacesToSentence(this string text, bool preserveAcronyms = true)
	{
		if (string.IsNullOrWhiteSpace(text))
			return string.Empty;
		StringBuilder newText = new StringBuilder(text.Length * 2);
		newText.Append(text[0]);
		for (int i = 1; i < text.Length; i++)
		{
			if (char.IsUpper(text[i]))
				if ((text[i - 1] != ' ' && !char.IsUpper(text[i - 1])) ||
				    (preserveAcronyms && char.IsUpper(text[i - 1]) && 
				     i < text.Length - 1 && !char.IsUpper(text[i + 1])))
					newText.Append(' ');
			newText.Append(text[i]);
		}
		return newText.ToString();
	}
}