title: Is there a way to replace the end of a string, starting at a given substring
body: <p>I have the string <code>banana | 10</code> and want to replace everything from <code>| </code> to the end of the string with <code>9</code>. The output I want would be <code>banana | 9</code>. How could I achieve this? I've looked into <code>.replace()</code>, <code>.split()</code> and converting the string into a list of characters, and looping over them until I find the bit that should be replaced, but just couldn't figure it out.</p>