develooper Front page | perl.beginners | Postings from May 2007

zero width lookahead match

Thread Next
From:
Sharan Basappa
Date:
May 30, 2007 04:58
Subject:
zero width lookahead match
Message ID:
8a31202a0705300457l38219d07s8a236d11af4e2db0@mail.gmail.com
Hi All,

I have some background working with scanners built from Flex. And I have
used lookahead capability of flex many a times. But I dont understand the
meaning of ZERO in zero lookahead match rule i.e. (?=pattern)

For example, to capture overlapping 3 digit patterns from string $str =
123456
I use the regex @store = $str =~ m/(?=(\d\d\d))/g;
So here the regex engine actually looks ahead by chars digits.

The other question I have is - how does regex engine decide that it has to
move further its scanner by 1 character everytime since I get output 123 234
345 456
when I run this script ?

Regards,
Sharan

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About