in reply to Re^3: ZERO_LENGTH match
in thread ZERO_LENGTH match
The output is:#!/usr/bin/perl use re "eval"; # (?{ CODE }) is a classical zero-width assertion # that allways succeeds and it is used only for its # side-effects. my $non_zero_width = 'a(?{ print 1 })'; my $zero_width = '(?{ print 2 })'; # These two should be equivalent according to perlre. my $re1 = qq/ (?: $non_zero_width | $zero_width )* /; my $re2 = qq/ (?: $non_zero_width )* | (?: $zero_width )? /; # But are they really? $_ = 'aaabbb'; print "\n-----------------\n"; /$re1/x; print "\n-----------------\n"; /$re2/x; print "\n-----------------\n";
|
|---|