in reply to Re^2: simple regex help
in thread simple regex help
output:#!/usr/bin/perl use strict; use warnings; use HTML::TokeParser::Simple; my $html = do{local $/; <DATA>}; my $p = HTML::TokeParser::Simple->new(\$html) or die "can't parse string: $!\n"; while (my $t = $p->get_token){ last if $t->is_end_tag('span'); } my ($match, @li_stack); while (my $t = $p->get_token){ if ($t->is_start_tag('li')){ push @li_stack, 'li'; } if ($t->is_end_tag('li')){ if (@li_stack){ pop @li_stack; } else{ last; } } $match .= $t->as_is; } print "$match\n"; __DATA__ <li><span class="title">Title</span><ul><li>one</li><li>two</li></ul> +MATCH HERE </li>
update:<ul><li>one</li><li>two</li> MATCH HERE
uptdate 2
see ikegami's reply below.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: simple regex help
by ikegami (Patriarch) on Apr 18, 2007 at 17:52 UTC | |
by Fletch (Bishop) on Apr 18, 2007 at 17:59 UTC | |
by ikegami (Patriarch) on Apr 18, 2007 at 19:48 UTC |