regex module, or don't work as expected

Fabian Holler fho at mailinator.com
Tue Jul 4 11:12:43 EDT 2006


Hello Marc,

thank you for your answer.

Marc 'BlackJack' Rintsch wrote:
> In <44aa670d$0$7872$6e1ede2f at read.cnntp.org>, Fabian Holler wrote:

>> i have the following regex "iface lo[\w\t\n\s]+(?=(iface)|$)"
>> 
>> If "iface" don't follow after the regex "iface lo[\w\t\n\s]" the rest of
>> the text should be selected.
>> But ?=(iface) is ignored, it is always the whole texte selected.
>> What is wrong?
> 
> The ``+`` after the character class means at least one of the characters
> in the class or more.  If you have a text like:

Yes thats right, but that isn't my problem.
The problem is in the "(?=(iface)|$)" part.

I have i.e. the text:

"auto lo eth0
<MATCH START>iface lo inet loopback
bla
blub

<MATCH END>iface eth0 inet dhcp
         hostname debian"


My regex should match the marked text.
But it matchs the whole text starting from iface.
If there is only one iface entry, the whole text starting from iface
should be matched.

greetings

Fabian



More information about the Python-list mailing list