Finding if a line contains Hebrew characters in perl

Finding if a line contains Hebrew characters in perl

Gabor Szabo szabgab at gmail.com
Fri Apr 26 09:24:34 IDT 2013


On Thu, Apr 25, 2013 at 6:05 PM, ik <idokan at gmail.com> wrote:
> try this
>
> #!/usr/bin/env perl -w
> #
>
> use v5.14;
> use utf8;
>
> my $text = 'שלוabv';
>
> if ($text =~ /^[\x{5D0}-\x{5ea}]{3}/) {
>   say "yes";
> } else {
>   say "no";
> }

I'd probably use   \p{IsHebrew}  or \p{InHebrew} instead of the hexa code.
Check here: http://perldoc.perl.org/perluniprops.html to learn way more than
you'd probably want to :)

I also CC-ed Meir Guttman who is *the* Perl Unicode expert.
He might have something more correct to suggest.

Gabor



More information about the Linux-il mailing list