in reply to Re: RegExp breaks in Perl 5.10
in thread RegExp breaks in Perl 5.10
Out of more than 28K words, only 15 fail... I wouldn't think this is related to encoding.
Yes, this is definitely odd, in particular as the ó character, which was causing problems in your case, was not one of the problem chars in Slaven Rezic's test code (which I'm re-posting here for easy reference):
for my $chr (160 .. 255) { my $chr_byte = chr($chr); my $chr_utf8 = chr($chr); utf8::upgrade($chr_utf8); my $rx = qr{$chr_byte|X}i; print $chr . " " . ($chr_utf8 =~ $rx ? "ok" : "not ok") . "\n"; }
Here, it was mainly uppercase letters where the match failed.
Note that the matching is done case-insensitively (which you don't do in your module). However, when you remove the 'i' from the qr{}, everything seems to work fine... So, I played around with this a bit more, and in fact it turned out the bug is highly dependent on context (which could explain why most of your regexes kept working).
For example, this modified test code still works fine
for my $chr (160 .. 255) { my $chr_byte = chr($chr); my $chr_utf8 = chr($chr); utf8::upgrade($chr_utf8); my $rx = qr{uci$chr_byte|uci}; my $s = "uci$chr_utf8"; print $chr . " " . ($s =~ $rx ? "ok" : "not ok") . "\n"; }
but if you add another character to the second alternative in the regex, e.g.
... my $rx = qr{uci$chr_byte|uci_}; ...
(the underscore shown here can be any char, it seems) the match suddenly fails in all cases tested (160..255) — but only if the leading 3 chars of the alternative are "uci". Actually, there are a number of other weird cases, but I think I don't have to show them all here. :)
As already mentioned in that thread, the problem seems to be related to the new trie code, because if you set ${^RE_TRIE_MAXBUF} = -1; all weirdness disappears.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: RegExp breaks in Perl 5.10
by jfraire (Beadle) on Mar 07, 2008 at 07:06 UTC | |
by almut (Canon) on Mar 07, 2008 at 18:21 UTC | |
by jfraire (Beadle) on Mar 07, 2008 at 20:02 UTC |