#python - Sun 18 Feb 2007 between 19:49 and 20:30

cybercobraJerub: and yet the Rubyites drool over that
Jerubcybercobra: but that's because most of the 'cool' stuff in ruby is monkeyhacks.
Jerubcybercobra: adding methods to built in types? monkeyhacks. modifying built in types? monkeyhacks.
library doesn't do what you want? monkey hack it and call it a feature.
Peperpattern="%s(?!(-)?[a-zA-Z])" % (self.source)
Can I somehow rule out lines beginning with foo?
Peper(in the regex)
deltab: but in the same pattern?
Peperand I don't need to put anything in between?
>>> re.sub("^(?!foo)bar(?!blah)","test","blah bar barblah")
'blah bar barblah'
deltab: I would like to get "blah test barblah"
can I somehow add (.*) to the regex but do not sub it?
deltabPeper: "blah bar barblah" doesn't start with 'bar'
sproingieyou'll sub what you match. use a backref if you want to keep it
Peperre.sub("bar(?!blah)","test","blah bar barblah")
'blah test barblah'
I want this, but omit lines starting with foo
when I just add ^(?!foo) it breaks my match
re.sub("(?!foo)(.*)bar(?!blah)","\g<1>test","bar bar barblah")
'bar test barblah'
using \g removes all subs but last
deltabor you could use if not s.startswith('foo')
Peperyeah, but I wanted to do it with regex as I am working on whole files with re.MULTILINE
sproingie: did you mean using /g in replace string?
HydraPheetzWould using an iterator be faster than using a for loops to read through a (rather long) list of files?
define "using an iterator"
marienzthe most common way to use an iterator is by using a for loop.
so one of us is misunderstanding something here :)
Bah, I might have gotten sidetracked with something
Peper>>> re.sub("^(?!foo)(?=.*)bar(?!blah)","test","blah blah bar bar barblah")
'blah blah bar bar barblah'
why doesn't that work?
sproingie(?=.*) is completely meaningless

Page: 2 9 16 23 30 37