How to remove everything after the last number in a string
<p>I have strings like this:</p>

<pre><code>w = 'w123 o456 t789-- --'
</code></pre>

<p>My goal is to remove everything after the last number, so my desired output would be</p>

<pre><code>w123 o456 t789
</code></pre>

<p>It is not always the same ending, so <code>-- --</code> is just one example.</p>

<pre><code>import re

re.sub('(.*?)(\d)', '', w)
</code></pre>

<p>gives me</p>

<pre><code>'-- --'
</code></pre>

<p>How can I modify the command so that it removes this part?</p>

<pre><code>st = 'w123 o456 t789-- --'
print st.rstrip()
"w123 o456 t789'
</code></pre>

python regex