Part 1:
Your problem may be that you've escaped the wrong parens: 1

my($first, $second, $third) = $text =~ /(\([a-z]*\))(?:\s|_|$)/gi; print "$first and $second and $third\n";

Part2:

no warnings 'uninitialized'; my $count = $text =~ s/(\([a-z]*\))(?:\s|_|$)/$1$2/gi; print $count; use warnings;

output, parts 1 and 2:

(network) and (test) and (ifcfg) 3

Part 3:
I'm not at all sure I understand what you want. Please clarify whether you're talking about multiple copies of a parenthesized word or simply "more than 3 parenthesized words in your string."

Update: Oops, meant to say but forgot to write it down, split to an array would also be a valid approach -- perhaps better than above.
Also, though I haven't worked it out, it seems that tr/// might also represent a possibility.

Update2: Adding note 1 -- or the problem may be that I read the OP as seeking to capture the encasing parentheses... which may be true, but is *not* specifically asserted. ...and if 'untrue,' apologies for the initial observation.


In reply to Re: Extracting multiple matches from Reg Ex by ww
in thread Extracting multiple matches from Reg Ex by rookie_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.