in reply to international case insensitive searched with Perl

#!perl use 5.014; use warnings; my $string = 'LÉGER'; print $string =~ /léger/i ? 'matched' : 'no match';

Prints 'matched' for me.

... of course if you're using an older version of perl, you need to put a little more work into enforcing a match under Unicode rules.

TJD

Replies are listed 'Best First'.
Re^2: international case insensitive searched with Perl
by Anonymous Monk on Oct 03, 2011 at 20:05 UTC
    More info:

    use feature 'unicode_strings' is the magic that works in 5.14.

    Check out 'The "Unicode Bug"' in  perldoc perlunicode

    TJD

Re^2: international case insensitive searched with Perl
by chrestomanci (Priest) on Oct 04, 2011 at 09:13 UTC
Re^2: international case insensitive searched with Perl
by mwhiting (Beadle) on Oct 04, 2011 at 15:57 UTC
    What kind of extra work is involved to make it match under unicode rules? I'm guessing it's a bit, so I might end up doing an customer-specific workaround to deal with it for them.
      use feature 'unicode_strings' tells perl to assume all strings are unicode.

      use utf8 tell perl to assume all strings in the current source file are unicode.

      Opening input files with a  :encoding layer will tell perl that the resulting strings are unicode.

       use encode contains subs that can be used to mark or convert strings from any other source as/to unicode.

      Hope this helps

      TJD