in reply to Reg Ex problems....

This works (i would have to run but will explain later if needed, and yes it assumes a lot (for instance that the stuff in NAME NAME will be all \w chars) but maybe it will give you a nudge in the right direction:
use strict; my $stuff = <<EOF; JUNK JUNK NAME NAME PANE THIS IS OTHER JUNK BAH EOF if ($stuff =~ m/(\w+ \w+)\nPANE/) { print $1; } ;
as for part 2. you are probably using a greedy .*, which would probably be alleviated by changing it to .*? or better yet [^"]+

update: You say that you are left with a result like this:

abcddeds. name name pane pane date
so you can try something like so:
use strict; my $string = ' abcddeds. name name PANE pane date'; if ($string =~ /(\w+ #one or more word chars (alphanumeric plus +_ matched) \s+ #at least one space \w+ #one or more word chars ) #close capturing parens \s+ #another space pane #matches pane /ix #"i" makes it case insensitive x makes it s +o #i can add comments ) { print $1; }
you should really take a look at perlre, and try to figure out why what I initially wrote failed against what you say the results looked like. Again though I took a lot of liberty in assuming that "name name" would contain a only alphanumeric chars. The i modifier was added as initially you had PANE, and now it is pane.

-enlil

Replies are listed 'Best First'.
Re: Re: Reg Ex problems....
by Anonymous Monk on Jan 09, 2003 at 06:20 UTC
    Enlil, Thanks for the reply, but unfortunately it didn't work me. I rechecked my code and it seems that after removing all the HTML tags from the HTML page, I have a result like
    abcddeds. name name pane pane date
    All I need to get is the "name name" before the "pane". Do you think the empty spaces could be causing a problem? Thanks.