[MacPerl-AnyPerl] negative lookahead xhtml tag
hi we need to replace tags like: to: it seems so simple but i am on the verge of giving up understanding the negative lookahead logic. this is how far i have come (obviously not working) my $src = qq(); $src =~ s/(]+\/))>/$1\/>/ig; print $src anyone with a clearer mind that can help on this ? thanks! ../allan
Re: [MacPerl-AnyPerl] negative lookahead xhtml tag
On Tue, Sep 17, 2002 at 12:00:45PM +0200, allan juul wrote: > hi > > we need to replace tags like: > > > > to: > > > > > it seems so simple but i am on the verge of giving up understanding the > negative lookahead logic. > > this is how far i have come (obviously not working) > > my $src = qq(); > $src =~ s/(]+\/))>/$1\/>/ig; > print $src The negative lookahead part is fine, except that it doesn't actually match the rest of the tag, so your replacement puts the /> in the middle of the tag and leaves the rest intact. I think this will work pretty well: $src =~ s,(]+)(?,$1 />,ig; Ronald
Re: [MacPerl-AnyPerl] negative lookahead xhtml tag
"Ronald J. Kimball" wrote: > > my $src = qq(); > > $src =~ s/(]+\/))>/$1\/>/ig; > > print $src > > The negative lookahead part is fine, except that it doesn't actually match > the rest of the tag, so your replacement puts the /> in the middle of the > tag and leaves the rest intact. correct, i mangabed to paste the wrong code, but nevermind > I think this will work pretty well: > > $src =~ s,(]+)(?,$1 />,ig; yes of couse, lookbehind ;) hmm, would it be possible to actually do it without using lookbehind (or even lookahead) you think? thanks ../allan
Re: [MacPerl-AnyPerl] negative lookahead xhtml tag
on 9/17/02 11:24 AM, [EMAIL PROTECTED] purportedly said: >> I think this will work pretty well: >> >> $src =~ s,(]+)(?,$1 />,ig; > > > yes of couse, lookbehind ;) > > hmm, would it be possible to actually do it without using lookbehind Yes, if you don't mind re-writing tags that are already XHTML compliant: $src =~ s|(|$1 />|ig; Keary Suska Esoteritech, Inc. "Leveraging Open Source for a better Internet"