regex for replacing \r\n
Patrick Bothe
irrwitz at hotmail.com
Mon Aug 7 08:30:30 EDT 2006
abcd wrote:
> [...]
> ultimately i am trying to replace all \r\n with somethign else, say
> BLAH.
>
> For example:
> This is a message
> on a new line
>
> would become:
> This is a messageBLAHon a new line.
Concluding from your question I think you might be happy with a simple
string `.replace`:
>>> s = 'This is a message\r\non a new line'
>>> print s
This is a message
on a new line
>>> s.replace('\r\n', 'BLAH')
>>> print s
'This is a messageBLAHon a new line'
Regards,
Patrick
--
2 does not equal 3. Even for large values of 2.
More information about the Python-list
mailing list