in reply to Re: Re: regex problem...
in thread regex problem... parsing html font tags

well, i think i can do it, but in this code:
$p = HTML::Parser->new(api_version => 3, start_h => [sub { ... }, "self,tagname,attr,text"], );
how do i replace the starting font tag *and* the text contained in the font tags with something generated in sub { ... }?

Replies are listed 'Best First'.
Re: Re: Re: Re: regex problem...
by wog (Curate) on Oct 09, 2001 at 23:58 UTC
    What you'd probably want to do is setup handlers for end tags and text, and have all handlers append to a string the text you want them replaced with or the original the text if you don't want them replaced.

    For handling ending FONT tags, you can catch the end of tag event and insert the appropriate ending tag. If the ending tag may vary you can keep (an) array(s) indicating what type of ending tag(s) to use (each element telling you information for one tag), push onto them when you encounter a start FONT tag, and pop off them when you encoutner an end FONT tag and output the appropriate tags.

    (update: last paragraph rewritten)