Thread Zu perlfaq: "How can I make \w match national character sets?" (10 answers)
Opened by Gast at 2009-10-17 18:05

Gast Gast
 2009-10-17 18:05
#127049 #127049
http://perldoc.perl.org/perlfaq6.html#How-can-I-ma...\w-match-national-character-sets?

Put use locale; in your script. The \w character class is taken from the current locale.

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use utf8;
use locale;
use POSIX qw( locale_h );

my $locale = setlocale( LC_CTYPE );
say $locale;     # de_DE.UTF-8


my $string = 'abcäöüß';
my @match = $string =~ /(\w)/g;

say "@match";   # a b c


Was muß ich hier noch ändern, damit auch die Umlaute matchen?

View full thread Zu perlfaq: "How can I make \w match national character sets?"