On 5/3/05, Nicholas Clark <[EMAIL PROTECTED]> wrote:
> Is this behaviour documented anywhere?
> 
> perl -le '@c = " one two three" =~ /(?: (\S+))+/; print foreach @c'
> three
> 
> Specifically that captures inside groupings that repeat capture the last
> string.
> 
> I can't find it in perlre*.pod

No. Me either, nor could I actually find any proper documentation for
the (pattern) which actually surprised me. However I do believe its
implicit if you realize that ( is just (for some definition of 'just')
a  zero width pattern which always matches and sets the start position
of its respective buffer, likewise ) when accompanied by a balanced
'(' is just a zero-width pattern which always matches and sets the end
position of its respective buffer. So the pattern says

Repeat  zero or more times:
    mark start of buffer, match \S 1 or more times, mark end of buffer 

Also for the record  ive seen a fair number of posts on Perlmonks that
explain or exploit this property.

Cheers,
Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Reply via email to