in reply to Can I change \s?
\s is suppose to match U+00A0 and sometimes does. It's a bug in Perl that cannot be fixed for backwards compatibility reasons. You can indicate you want the fix using feature unicode_strings. In earlier versions of Perl, you can also work around the bug by upgrading the string's internal format.
use strict; use warnings; use feature qw( say ); my $string = chr(160); no feature qw( unicode_strings ); say $string =~ /^\s*$/ ? 1 : 0 ; # 0 use feature qw( unicode_strings ); say $string =~ /^\s*$/ ? 1 : 0; # 1 no feature qw( unicode_strings ); utf8::upgrade($string); say $string =~ /^\s*$/ ? 1 : 0; # 1
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Can I change \s?
by JavaFan (Canon) on Oct 28, 2011 at 23:17 UTC |