On Oct 28, Matthias Leopold said:

i want to search for a pattern in html text and replace only those occurences that are not enclosed inside <> (html tag, not perl operator).

It's easiest to use a real HTML parser. Otherwise, you'll probably get false positives and what-not.

$string =~ s/$pattern/test for <> or similar; else replace/ge;

sounds like an easy task but i haven't managed to accomplish it yet.

Parsing HTML (which really is what you're looking to do) always sounds easy until you see how it's done correctly. Then you feel better off using a module to do it for you. (Guilt-free, I might add.)

I'd suggest going to search.cpan.org and looking for HTML:: which should yield several matches. I think HTML::TokeParser (or HTML::TokeParser::Simple) would be your best bet here.

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to