Mr. Shawn H. Corey wrote:
> 
> Perl captures on a strict left-to-right policy.  Start at the left of
> the regular expression and every opening parenthesis will be captured in
> the next numbered variable.  For your first example:
> 
>   /(lang)|(id)="(\S+)"/g
>    ^      ^     ^
>    $1     $2    $3
> 
> The 'g' flag at the end makes it repeatedly apply the match.  Since 'id'
> appears in $string before 'lang', the first match is: $1 is undef, $2 =
> 'id', $3 = 'dontcare'.  The second match gives: $1 = 'lang', $2 = undef,
> $3 = undef.  Note that because of its level of precedence, the
> alteration applies to the whole pattern so $2 and $3 are undef when
> 'lang' is matched.

That would be 'alternation'. Sorry to be finicky, but your sentence loses its
sense with your mistake, and this is a beginners' group.

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to