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


In reply to Re: Reg Ex problems.... by Enlil
in thread Reg Ex problems.... by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.