in reply to Re: testing if a string is ascii (^)
in thread testing if a string is ascii
(update: this is just a stylistic difference relative to $str !~ /[^\0-\x7f]/ -- to avoid the cognitive challenge of the double-negative)sub nonascii { local $_ = shift; /[^\0-\x7f]/; # or /[^[:ascii:]]/ } for my $test ( split( " ", "foo bar b\xe1 baz" )) { next if ( nonascii( $test )); print "$test\n"; }
|
|---|