List Info

Thread: Re: regexp inconsistency




Re: regexp inconsistency
user name
2007-10-24 04:05:42
On 24/10/2007, Abigail <abigailabigail.be> wrote:
> > #!/usr/bin/perl -w
> > my $foo = 'H';
> > my $bar = ($foo =~ /^(w.)*w$/);
> > my $baz = ($foo =~ /^(pL.)*pL$/);
> > print "[$bar] [$baz]n";
> >
> > Example output:
> > [1] []
> >
> > You would expect to get the same result in both
cases.
>
>
> The optimizer seems to be the cause of this:
>
>   $ perl -Mre=debug -e '"H" =~
/^(pL.)*pL$/'
>   [ .. ]
>   Guessing start of match in sv for REx
"^(pL.)*pL$" against "H"
>   Found floating substr ""$ at offset 1...
>   start_shift: 1 check_at: 1 s: 0 endpos: 1
>   Could not match STCLASS...
>   Match rejected by optimizer
>
>
> both "H" =~ /^(pL.)*pL/ and "H"
=~ /^pL$/ do match.

Also, if you upgrade the matched string to utf-8, you get
the correct result.

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )