Re: [MacPerl-AnyPerl] negative lookahead xhtml tag
[email protected] (allan) Tue, 17 Sep 2002 19:24:15 +0200
| Newsgroups | perl.macperl.anyperl |
|---|---|
| Message-ID | <[email protected]> |
"Ronald J. Kimball" wrote: > > my $src = qq(<img src="Some/Path" anthing="anything">); > > $src =~ s/(<img(?![^>]+\/))>/$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,(<img[^>]+)(?<!/)>,$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