problem with newlines in regexp substitution
- From: Florian Schulze <florian.proff.schulze@xxxxxxx>
- Date: Thu, 23 Feb 2006 18:15:22 +0100
See the following results:
Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
'\n'import re
s = "1"
re.sub('1','\\n',s)
'\\n''\\n'
'\\n're.sub('1',r'\\n',s)
'\\n's.replace('1','\\n')
'\n'repl = '\\n'
re.sub('1',repl,s)
'\\n's.replace('1',repl)
Why is the behaviour of the regexp substitution so weird and can I prevent that? It breaks my asumptions and thus my code.
Regards,
Florian Schulze
.
- Follow-Ups:
- Re: problem with newlines in regexp substitution
- From: James Stroud
- Re: problem with newlines in regexp substitution
- Prev by Date: datetime iso8601 string input
- Next by Date: Re: need help regarding compilation
- Previous by thread: datetime iso8601 string input
- Next by thread: Re: problem with newlines in regexp substitution
- Index(es):