in reply to how to remove a string from end of a line
Any of the following might serve as the strategy that solves not only the one example you gave, but all the other cases:
The point is that the solution depends on what you know about the input data - and how consistent the input is and what kinds of consistency it has (or doesn't have) - as well as how the output should differ.
I tend to do a lot of "defensive programming" whenever it comes to applying this sort of filter to text data - a lot of data diagnosis (where possible) before writing the code, and enough tests in the code to make sure that the filter does what it's supposed to do, and reports when the input doesn't meet the necessary expectations.
|
|---|