How to use regex to disallow non-digts but allow a dot in Python?
<p>I am new to regex and trying to remove all <strong>non-digts</strong> but keep the <strong>dot</strong> (<strong>.</strong>) of a string:</p>

<pre><code>x = ['ABCD, EFGH ', ' 20.9&amp;dog; ', ' IJKLM /&gt;']
</code></pre>

<p>So far I have tried the following:</p>

<pre><code>&gt;&gt;&gt; x = re.sub("\D", "", x)
209
</code></pre>

<p>However I am trying to get the following outcome:</p>

<pre><code>20.9
</code></pre>

<p>Thanks.</p>

<p>This is a simple requirement which can be made explicit:</p>

<pre><code>for item in x:
    print re.sub(r'[^0-9.]', "", item)
</code></pre>

python regex python-2.7