mb_ereg_match()
$list = array(
'かな',
'カナ',
'012',
'ABC',
'漢字',
);
mb_regex_encoding("UTF-8");
print "全角かな\n";
foreach ($list as $x) {
if (mb_ereg_match('^[ぁ-んー]+$', $x)) {
print "OK: " . $x . "\n";
} else {
print "NG: " . $x . "\n";
}
}
print "全角カナ\n";
foreach ($list as $x) {
if (mb_ereg_match('^[ァ-ヶー]+$', $x)) {
print "OK: " . $x . "\n";
} else {
print "NG: " . $x . "\n";
}
}
print "全角数字\n";
foreach ($list as $x) {
if (mb_ereg_match('^[0-9]+$', $x)) {
print "OK: " . $x . "\n";
} else {
print "NG: " . $x . "\n";
}
}
print "全角英字\n";
foreach ($list as $x) {
if (mb_ereg_match('^[A-Za-z]+$', $x)) {
print "OK: " . $x . "\n";
} else {
print "NG: " . $x . "\n";
}
}
print "全角漢字\n";
foreach ($list as $x) {
if (mb_ereg_match('^[亜-腕 弌-熙 ]+$', $x)) {
print "OK: " . $x . "\n";
} else {
print "NG: " . $x . "\n";
}
}