I have created a function to 'filter' a string by removing various characters using the .Replace method, I am also removing anything at the end of the string that starts with '(' using the Substring method.
This all works fine, however I am wondering if there is a optimised better way of doing this as efficiency is important for me.
public static string filterHorseName(string horseName)
{
horseName = horseName
.Replace(" ", "")
.Replace("`", "")
.Replace("-", "")
.Replace("'", "")
.Replace("´", "")
.Replace("’", "")
.ToLower();
int index = horseName.IndexOf("(");
if (index > 0)
{
horseName = horseName.Substring(0, index);
}
return horseName;
}
Thank you.