I need to remove "Time" from some strings, if it is present as the last substring. The solution needs to work for these cases:
"AmpliTime" => "Ampli"
"IsoTimeTime" => "IsoTime"
"SometypeTimeAndThenTime" => "SometypeTimeAndThen"
"SometypeTimeAndThenTimeAbc" => "SometypeTimeAndThenTimeAbc"
I have tried something like this but it runs into problems if the word Time appears somewhere else besides the end.
long start = s.find("Time");
if (start > 0)
{
printf("%d\n", start);
s.erase(start, 5);
}
printf("%d\n", start);