public static string RemoveFromEnd(this string originalText, string textToRemove)
{
if (!originalText.EndsWith(textToRemove))
throw new InvalidOperationException(
String.Format("The original text is expected to end with '{0}', but it doesn't.", textToRemove));
return originalText.Substring(0, originalText.Length - textToRemove.Length);
}
}