Browse - programming tips - perl detect accented characters in a stringDate: 2011aug13 Language: perl Q. Best way to detect accented characters in a Perl string? A. Use the ever powerful match: sub hasAccents($) { my($a) = @_; return $a =~ m/[\x7F-\xFF]/s } sub exampleUse() { my $a = "line one\nhello\x88"; if (hasAccents($a)) { print "There are accents\n"; else { print "Just regular ASCII\n"; } }
Add a commentSign in to add a comment | Advertisements:
|