Does anyone know of a better / cleaner way to write the following:
GetSafeTagName(txtUserInput.text);
public static string GetSafeTagName(string tag)
{
tag = tag.ToUpper()
.Replace("'","`")
.Replace('"','`')
.Replace("&", "and")
.Replace(",",":")
.Replace(@"\","/"); //Do not allow escaped characters from user
tag = Regex.Replace(tag, @"\s+", " "); //multiple spaces with single spaces
return tag;
}
Thanks!
StringBuilder
. \$\endgroup\$