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.


In reply to Re^2: RegExp breaks in Perl 5.10 by almut
in thread RegExp breaks in Perl 5.10 by jfraire

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.