Check if the string contains Japanese
You can use regular expression to find out if the string contains Japanese. Use the following metacharacters to check for Kanji, Hiragana, and Katakana. The string must be an decoded string.
Character type | Metacharacters |
Chinese characters |
\p{Han} |
Hiragana |
\p{Hiragana} |
Kanakana |
\p{Katakana} |
use strict; use warnings; use utf8; my $str = 'Ai Uesan'; if ($str =~ /[\p{Han}\p{Hiragana}\p{Katakana}]/) { # Contains Japanese }