469,929 Members | 1,797 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

a re problem

>>> p.sub('','a\nbc')
'abc'
p.sub('','%s') % "a\nbc"

'a\nbc'

is it anyone got some idea why it happen?

Jul 19 '05 #1
3 1306


cheng wrote:
p.sub('','%s') % "a\nbc"

'a\nbc'

is it anyone got some idea why it happen?


Make that

p.sub('','%s' % "a\nbc")
Regards
/Mikael Olofsson

Universitetslektor (Senior Lecturer [BrE], Associate Professor [AmE])
Linköpings universitet

-----------------------------------------------------------------------
E-Mail: mi****@isy.liu.se
WWW: http://www.dtr.isy.liu.se/en/staff/mikael
Phone: +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
-----------------------------------------------------------------------
Linköpings kammarkör: www.kammarkoren.com Vi söker tenorer och basar!

Jul 19 '05 #2
"cheng" <ma******@spymac.com> wrote:
p.sub('','a\nbc') 'abc' p.sub('','%s') % "a\nbc" 'a\nbc'

is it anyone got some idea why it happen?

p.sub('', 'a\nbc') Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'p' is not defined
import re
p = re.compile("\n*")
p.sub("", "a\nbc") 'abc' p.sub("", "%s")

'%s'

</F>

Jul 19 '05 #3
thx for help :)

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Kostatus | last post: by
117 posts views Thread by Peter Olcott | last post: by
18 posts views Thread by Ian Stanley | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
2 posts views Thread by Mike Collins | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.