best way to get an integer from string without using regex
<p>I would like to get some integers from a string (the 3rd one). Preferable without using regex. </p>

<p>I saw a lot of stuff.</p>

<p>my string:</p>

<pre><code>xp = '93% (9774/10500)'
</code></pre>

<p>So i would like the code to return a list with integers from a string. So the desired output would be: <code>[93, 9774, 10500]</code></p>

<p>Some stuff like this doesn't work:</p>

<pre><code>&gt;&gt;&gt; new = [int(s) for s in xp.split() if s.isdigit()]
&gt;&gt;&gt; print new
[]
&gt;&gt;&gt; int(filter(str.isdigit, xp))
93977410500
</code></pre>

<p>Using regex (sorry!) to split the string by a non-digit, then filter on digits (can have empty fields) and convert to int.</p>

<pre><code>import re

xp = '93% (9774/10500)'

print([int(x) for x in filter(str.isdigit,re.split("\D+",xp))])
</code></pre>

<p>result:</p>

<pre><code>[93, 9774, 10500]
</code></pre>

python string int