I have a string of words, and I want to remove from each word the number of suffixes and prefixes (which are located in the array), and then save back the words in the string. Is there any suggestion please? thanks in advance.
The total number of suffixes and prefixes is more than 100, what is better to represent them? An array? Regex? Is there any suggestion please?
public static string RemoveFromEnd(this string str, string toRemove)
{
if (str.EndsWith(toRemove))
return str.Substring(0, str.Length - toRemove.Length);
else
return str;
}
This can work with suffixes, what about prefixes? Is there a quick way to do this for both suffixes and prefixes at a time? My line is too long.
source
share