in reply to Reg Ex problems....
as for part 2. you are probably using a greedy .*, which would probably be alleviated by changing it to .*? or better yet [^"]+use strict; my $stuff = <<EOF; JUNK JUNK NAME NAME PANE THIS IS OTHER JUNK BAH EOF if ($stuff =~ m/(\w+ \w+)\nPANE/) { print $1; } ;
update: You say that you are left with a result like this:
so you can try something like so:abcddeds. name name pane pane date
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.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; }
-enlil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Reg Ex problems....
by Anonymous Monk on Jan 09, 2003 at 06:20 UTC |