<div dir="ltr">=)<br>Indeed. But it will replace all dots including ordinary strings instead of numbers only.<br><br><div class="gmail_quote">On Tue, Aug 5, 2008 at 3:23 PM, Jeff <span dir="ltr"><<a href="mailto:jeffober@gmail.com">jeffober@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">On Aug 5, 7:10 am, Marc 'BlackJack' Rintsch <<a href="mailto:bj_...@gmx.net">bj_...@gmx.net</a>> wrote:<br>
> On Tue, 05 Aug 2008 11:39:36 +0100, Fred Mangusta wrote:<br>
> > In other words I'd like to replace all the instances of a '.' character<br>
> > with something (say nothing at all) when the '.' is representing a<br>
> > decimal separator. E.g.<br>
><br>
> > 500.675 ----> 500675<br>
><br>
> > but also<br>
><br>
> > 1.000.456.344 ----> 1000456344<br>
><br>
> > I don't care about the fact the the resulting number is difficult to<br>
> > read: as long as it remains a series of digits it's ok: the important<br>
> > thing is to get rid of the period, because I want to keep it only where<br>
> > it marks the end of a sentence.<br>
><br>
> > I was trying to do like this<br>
><br>
> > s=re.sub("[(\d+)(\.)(\d+)]","... ",s)<br>
><br>
> > but I don't know much about regular expressions, and don't know how to<br>
> > get the two groups of numbers and join them in the sub. Moreover doing<br>
> > like this I only match things like "345.000" and not "1.000.000".<br>
><br>
> > What's the correct approach?<br>
><br>
> In [13]: re.sub(r'(\d)\.(\d)', r'\1\2', '1.000.456.344')<br>
> Out[13]: '1000456344'<br>
><br>
> Ciao,<br>
> Marc 'BlackJack' Rintsch<br>
<br>
</div></div>Even faster:<br>
<br>
'1.000.456.344'.replace('.', '') => '1000456344'<br>
<div><div></div><div class="Wj3C7c">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br></div>