A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-January/051214.html below:

[Python-Dev] Unix line endings required for PyRun* breaking embedded Python

[Python-Dev] Unix line endings required for PyRun* breaking embedded Python [Python-Dev] Unix line endings required for PyRun* breaking embedded PythonJust van Rossum just at letterror.com
Thu Jan 20 09:48:41 CET 2005
Skip Montanaro wrote:

> Just re.sub("[\r\n]+", "\n", s) and I think you're good to go.

I don't think that in general you want to fold multiple empty lines into
one. This would be my prefered regex:

    s = re.sub(r"\r\n?", "\n", s)

Catches both DOS and old-style Mac line endings. Alternatively, you can
use s.splitlines():

    s = "\n".join(s.splitlines()) + "\n"

This also makes sure the string ends with a \n, which may or may not be
a good thing, depending on your application.

Just
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4