<?xml version="1.0" encoding="windows-1252"?>
<node id="935404" title="Re: Regex Matching Unicode and Regex Classes" created="2011-11-02 10:05:06" updated="2011-11-09 15:39:56">
<type id="11">
note</type>
<author id="832495">
choroba</author>
<data>
<field name="doctext">
Two days ago, I was having the same issues. My testing script is a bit more elaborate, but confirms your problem: &lt;c&gt;\w&lt;/c&gt; does not work under &lt;c&gt;use locale&lt;/c&gt;, whatever the locale is. If you need locale, use posix classes or unicode character properties (provided your locale is unicode based).
&lt;br&gt;
Discussion on the details can be found in [doc://perlunicode] and [doc://perllocale], but the relevant paragraphs are quite different in each version of Perl.

&lt;c&gt;
#!/usr/bin/perl

use warnings;
use strict;

my @p_locale = qw/C cs_CZ.UTF8 en_US.UTF8/;
my @locale = ('no locale', 'use locale');
my @posix  = (q(),
              'use POSIX qw/locale_h/; setlocale LC_ALL,"C"',
              'use POSIX qw/locale_h/; setlocale LC_ALL,"cs_CZ.UTF8"',
             );

for my $p_locale (@p_locale) {
    for my $locale (@locale) {
        for my $posix (@posix) {
            print "$p_locale  $locale  $posix\n";
            open my $OUT, '&gt;', 'l.perl' or die "$!";
            print {$OUT} &lt;&lt; "            OUT";
              $locale;
              $posix;
              my \@chars = qw/283 269 345 225
                  32
                  98 99 48 49 50 51 52
                  32
                  353 253 382 237/;
              my \$string = join q[], map chr, \@chars;
              binmode STDOUT, ':utf8';
              my \@regex  = (qr/(\\w+)/, qr/([[:alnum:]]+)/, qr/(\\p{Word}+)/);
              for my \$regex (\@regex) {
                  print "\t\$1" while \$string =~ /\$regex/g;
                  print "\n";
              }
              print sort qw/ci ch/;
              print "\n";
            OUT
            close $OUT;
            $ENV{LC_ALL} = $p_locale;
            system 'perl', 'l.perl';
        }
    }
}
unlink 'l.perl';
&lt;/c&gt;</field>
<field name="root_node">
935400</field>
<field name="parent_node">
935400</field>
</data>
</node>
