How do loose the /012

Moshe Zadka moshez at math.huji.ac.il
Wed Oct 6 02:12:07 EDT 1999


[Courtesy CC sent by mail]

On 5 Oct 1999, Alex wrote:

> >>> import re
> >>> text=re.sub('\n','',text)
> >>> text=re.sub('\.','.\n',text)
> >>> print text

I will kindly remind everyone that this is Python, not Perl. Hence, we
should not go the tortureous RegEx route, when we have the (in Python,
more efficient) string way.

In particular, string.translate and string.replace would do just as well,
and you wouldn't have to escape your ".", either.

--
Moshe Zadka <mzadka at geocities.com>. 
INTERNET: Learn what you know.
Share what you don't.





More information about the Python-list mailing list