in reply to how to make // not return what is in a parenthesis?

One way would be:

>perl -wMstrict -le "my $s = 'ABC1D A2D D3A foo4bar'; my @matches = $s =~ m{ A (?: BC)? (\d+) D }xmsg; print qq{'$_'} for @matches; " '1' '2'

Updates:

  1. In common with chromatic, I, also, cannot get the OPed code example to work as posted.
    I am going by the first regex in the OP: 'A(BC|)(.*)D'.
  2. Slightly altered code example to make results clearer.
  3. See the non-capturing grouping expression  (?:pattern) in the Extended Patterns section of perlre.

Replies are listed 'Best First'.
Re^2: how to make // not return what is in a parenthesis?
by beanryu (Novice) on Aug 01, 2010 at 02:04 UTC
    thank you so much sir, yes, this is what I am looking for, thanx a lot.