in reply to UTF8 versus \w in pattern matching
I'd say your file's encoding is not what you think it is.
use strict; use warnings; use Data::Dumper; use utf8; my $str = " 1 i á \x{3C3} _ "; # \x{3C3} = small sigma warn Dumper $str; $str =~ s/\w+//g; # delete all alpha-nums warn Dumper $str; warn "WORKS!" if $str =~ m/^ +$/;
C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/utf8.pl $VAR1 = " 1 i \x{e1} \x{3c3} _ "; $VAR1 = ' '; WORKS! at d:/tmp/pm/utf8.pl line 12.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
*) PM has problems displaying unicode characters like "σ" inside code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UTF8 versus \w in pattern matching (basic test)
by mldvx4 (Hermit) on Jul 06, 2021 at 11:45 UTC | |
by haj (Vicar) on Jul 06, 2021 at 12:25 UTC | |
by LanX (Saint) on Jul 06, 2021 at 12:56 UTC | |
by mldvx4 (Hermit) on Jul 06, 2021 at 13:03 UTC | |
by LanX (Saint) on Jul 06, 2021 at 15:23 UTC | |
by jo37 (Curate) on Jul 06, 2021 at 16:18 UTC | |
by haj (Vicar) on Jul 06, 2021 at 17:54 UTC | |
| |
by ikegami (Patriarch) on Jul 06, 2021 at 21:07 UTC |