I have strings that have the following pattern. Some text on some more text before some text.
How do I find
- the position of the word “before” and remove it with anything after it,
- and the position of the word ” on ” and remove it with anything before it?
Regular expressions are overkill for this. Just do a substring from where you find “on” to where you find “before”: