This grows out an an attempt to improve my fu by building an alternate solution (without using the experimental constructs offered in answers to Need Regex help...but now, my head is bloodied (from banging it against what's become a stone wall). Pray help me to an answer that causes me to slap and flatten that bloody forehead (as in "Oh.... yeah!!!!! How could I have missed that?").

TEST1 is supposed to match entries with BOTH EXT and INT curly delimiters update: so it SHOULD capture 2 matches in Dataline 1 but (per testing and hash contents) it is capturing only the first match in DataLine 1 -- SEE note 2. It correctly captures a single match in DataLine2

NOTE 1: regex in extended format & commented is update in the readmore (was referenced to ww's scratchpad)

NOTE 2: IF this is modified with an initial .* before the capture, the "{three 1 1 {...} {...}}" matches

#!C:/perl/bin -w use strict; use Data::Dumper::Simple; use vars qw ( $i $j $tmp $test @data @found $found %h ); $i = 1; # tracking counter - in full version does NOT necessarily +== $j $j = 0; # track datalines %h = (); while (<DATA>) { push @data,$_ ; } foreach $test(@data) { test1($test); } &hashprint; exit(); ################ subs ############# sub test1 { # first, get rid of previous array conents (needed i +n full vers) undef(@found); # Categorized Q&A book answer; "@found = ();" is an +alternate $j++; print "\n\t ***** STARTING dataline $j ****\n\n"; if ($test =~ /(\{{1}[a-z]{4,5}\s\d\s\d\s[^}]+?\}\s\{[^}]+?\}{2})/gx ) + # see NOTE1 { if ( $1 ) { $tmp = "\t\$j" . $j . "\$i". $i . ": " . $1 . "\n"; push @found, $tmp; &hashify; print "TEST1 regex, dataline $j found match(es)\n"; print "\t $1\n"; } else { print "\t TEST1 dataline $j, NO matches.\n"; } } $i++; return($i) } # end sub test1 # (more similar tests here in full version) ############## sub hashify { $h {'datalinej'.$j."_i".$i} {"j".$j."i" .$i} = "@found"; # get all @fo +und's elements into hash ??? $tmp = ''; return(); } # end hashify ########### sub hashprint { print "\n\t\t~~~~~~~~~~~~~~~~ Dumping hash (HoA)\n"; print Dumper (%h); print "\t\t~~~~~~~~~~~~~~~~ ending dump\n"; } # end sub hashprint and end subs __DATA__ DataLine1 {error 1 1 {^E 0-20-9:0-50-9:0-50-9.*$} {^E 0-20-9:0-50-9:0- +50-9.*$}} {three 1 1 {^.*35=A.*$|^.*35=5.*$} {^.*35=A.*$|^.*35=5.*$}} + {fixv 1 1 ^.*VFIXFxProxy.*Disconnected ^.*VFIXFxProxy.*Disconnected} DataLine2 error 1 1 {^E 0-20-9:0-50-9:0-50-9.*$} {^E 0-20-9:0-50-9:0-5 +0-9.*$} {three 1 1 {^.*35=A.*$|^.*35=5.*$} {^.*35=A.*$|^.*35=5.*$}} { +fixv 1 1 ^.*VFIXFxProxy.*Disconnected ^.*VFIXFxProxy.*Disconnected}
update Output is:
***** STARTING dataline 1 **** TEST1 regex, dataline 1 found match(es) {error 1 1 {^E 0-20-9:0-50-9:0-50-9.*$} {^E 0-20-9:0-50-9:0-5 +0-9.*$}} ***** STARTING dataline 2 **** TEST1 regex, dataline 2 found match(es) {three 1 1 {^.*35=A.*$|^.*35=5.*$} {^.*35=A.*$|^.*35=5.*$}} ~~~~~~~~~~~~~~~~ Dumping hash (HoA) %h = ( 'datalinej1_i1' => { 'j1i1' => ' $j1$i1: {error 1 1 {^E 0-20-9: +0-50-9:0-50-9.*$} {^E 0-20-9:0-50-9:0-50-9.*$}} ' }, 'datalinej2_i2' => { 'j2i2' => ' $j2$i2: {three 1 1 {^.*35=A.*$ +|^.*35=5.*$} {^.*35=A.*$|^.*35=5.*$}} ' } ); ~~~~~~~~~~~~~~~~ ending dump
and, update per merlyn's note, the commented regex for TEST1 is:
$test =~ / ( # capture \{{1} # SINGLE open curlybrace [a-z]{4,5} # followed by 4 or 5 lowercase letters \s\d\s\d\s # fol by whitespace, digit, whitespace, digit, + space [^}]+? # fol by anything_not_a_closingcurly, one-or-m +ore_times-but-as_few_as_poss \}\s\{ # closingcurly fol by whitespace fol by opencu +rly (tween element 4 and element 5) [^}]+? # fol by anything_not_a_closingcurly, one-or-m +ore_times-but-as_few_as_poss \}{2} # closingcurly twice )/gx; # end capture, global, xtended syntax, end if_t +est
update (approx 0200 UTC, 2005-09-17) And if you've read this far; thanks. I'm now trying to wrap my head around ikegami's and util's replies... after which I'll update again.

In reply to multiple matches in regex by ww

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.