regex for replacing \r\n

A

abcd

I am trying to get a regex that will match \r\n in a string.
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.

any ideas? i tried

re.compile('\r\n').match("This is a message" + os.linesep + "on a new
line") ....but no match. And I am on windows, so os.linesep gives
'\r\n'

thanks
 
P

Patrick Bothe

abcd said:
[...]
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`:This is a message
on a new line'This is a messageBLAHon a new line'

Regards,
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top