in reply to Quick regex for finding something in an OPTION tag

The regex you want is trivial: /^0_memberOf_/. Figuring out where to use it is more interesting. Using HTML::Parser you could:

use warnings; use strict; use HTML::Parser; my $html = <<HTML; <html> <body> <option value="0_memberOf_x">Ya want this?</option> </body> </html> HTML my $h = HTML::Parser->new (); my @stack; $h->handler (start => sub {return startOption (\@stack, @_);}, 'tag, +attr'); $h->handler (text => sub {return optionText (\@stack, @_);}, 'text'); $h->handler (end => sub {return endOption (\@stack, @_);}, ''); $h->parse ($html); sub startOption { my ($stack, $tag, $attr) = @_; push @$stack, [$tag, $attr->{value}]; } sub optionText { my ($stack, $text) = @_; return unless @$stack; push @{$stack->[-1]}, $text; } sub endOption { my ($stack) = @_; my ($tag, $match, $text) = @{pop @$stack}; return unless $tag eq 'option' && defined ($match) && $match =~ /^ +0_memberOf_/; print "$match: $text\n"; }

Prints:

0_memberOf_x: Ya want this?

Perl reduces RSI - it saves typing