in reply to Regex Subexpressions

Are you looking for:
@matches = m/(((a)b)c)/ and print "@matches\n";
?

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Regex Subexpressions
by liverpole (Monsignor) on Sep 10, 2005 at 03:02 UTC
    Wow!  Now that's a great answer!

    Let me just add the following, since it took me a few minutes to see exactly what you were doing, as well as making it conform to the original requirements for the output:

    $_ = "abc"; # Regex match of /.../ uses $_ when =~ is unspecified # Nicely solves the problem stated, and demonstrates list assignment # to a regex capture. # @matches = m/(((a)b)c)/ and print join "\n", reverse @matches;
    I realized a "reverse" was necessary, and then immediately fell into the trap of putting it before the "join".  I like your answer a lot for its succinct approach!
      Does your solution have to find "ab" in "abd"? If so, the above won't work.