Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Two days ago, I was having the same issues. My testing script is a bit more elaborate, but confirms your problem: \w does not work under use locale, whatever the locale is. If you need locale, use posix classes or unicode character properties (provided your locale is unicode based).
Discussion on the details can be found in perlunicode and perllocale, but the relevant paragraphs are quite different in each version of Perl.
#!/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, '>', 'l.perl' or die "$!"; print {$OUT} << " 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{W +ord}+)/); 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';

In reply to Re: Regex Matching Unicode and Regex Classes by choroba
in thread Regex Matching Unicode and Regex Classes by McA

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2022-01-18 01:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (52 votes). Check out past polls.

    Notices?