php - empty range in char class
904
I have this script
mb_regex_encoding('UTF-8');
mb_internal_encoding('UTF-8');
$yomi = 'アイウエオャュョハ゛ヒ゜';
if (mb_ereg('^[ヲ-゜]+$', $yomi)) {
return true;
}
return false;
When I run it I get a warning:
[Warning]: mb_ereg(): mbregex compile err: empty range in char class
I googled but can't find a solution. Help please.
Answer
Solution:
If you are looking for a half-width katakana regex, you can use the following validation:
See the regex demo
IDEONE demo:
Output is only
カタカナ is valid!
.