in reply to Re: Re: Regex perplexity
in thread Regex perplexity

Nevermind; I'm dumb. I just add this line:
# slice out the appropriate part of the string ($string) = $string =~ /(><a name = $id>.*?<\/pre>)/s;

to the beginning of the subroutine and remove the $id_flag weirdness and it works great. Thanks for the example code, and the multi-loop approach. Apparently there _are_ some things a regex can't do!

Cheers all,

Evan

Replies are listed 'Best First'.
Re: Re: Re: Re: Regex perplexity
by eweaverp (Scribe) on Jun 30, 2003 at 22:50 UTC
    And... that made me realize that this:
    sub FindPositions { my $string = $_[0]; my $id = $_[1]; # slice out the appropriate part of the string ($string) = $string =~ /(><a name = $id>.*?<\/pre>)/s; my @positions = $string =~ m/<a name = $id>.*?Query: (\d+).*?Sbjct: +(\d+).*?<\/pre>/s; push (@positions, $string =~ m/<a name = $id>.*Query: \d+\s+[a-z]+ ( +\d+)\n.*\nSbjct: \d+\s+[a-z]+ (\d+)\n<\/pre>/s); return @positions; }
    works too. First and last. Hmm. Anyway...