John W. Krahn wrote:
> Rob Dixon wrote:
>> Vyacheslav Karamov wrote:
>>> my @matches = $text =~ /$regex/g;
>>> foreach my $arr (@matches)
>>> {
>>> print "$arr\n" if defined $arr;
>>> }
>> You can retrieve the start and end positions of the last successful matches
>> from
>> the @- and the @+ arrays. The start and end of $1 is in $-[0] and $+[0] for
>
> The start and end of $1 are in $-[1] and $+[1]. $-[0] and $+[0] contain
> the start and end of the last successful match.
>
> perldoc perlvar
>
>> instance. Like this
>>
>> my $regex = qr/\([^)]+\)|\[[^]]+\]/s;
>>
>> while ($text =~ /($regex)/g) {
>> print "$-[0] - $+[0] = $1\n";
>
> while ( $text =~ /$regex/g ) {
> print "$-[0] - $+[0] = ", substr( $text, $-[0], $+[0] - $-[0] ), "\n";
>
>
>> }
Thanks John.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/