On Oct 25, Pine Yan said:

This is a segment of code to do string search:

my $email = "\pineyan";
my $name = "\\pine";

if($email =~ /($name)/) {
       print "Found my name: $name!\n";
}

and I got the following error when running:

        Can't find unicode character property definition via main->i or
i.pl at unicode/Is/i.pl line 0

Perl sees your regex as /(\pine)/, and \pi is a shortcut for \p{i} which means "Unicode property 'i'". To get around this, do:

  if ($email =~ /(\Q$name\E)/) { ... }

The \Q...\E auto-quotes any regex-related characters, so that they're matched literally.

P.S. My last name is Pinyan (awfully close to your full name). It's pronounced the same way, I'm told, as "pinyin", the process by which Chinese characters are transliterated into English "words".

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to