php 한글, 한문, 영문, 일문, 숫자 구분 방법

if (preg_match_all('!['.'\x{0030}-\x{0039}'.']+!u', $str, $match))
{
        return '숫자';
}
if (preg_match_all('!['.'\x{0061}-\x{007a}|\x{0041}-\x{005a}'.']+!u', $str, $match))
{
        return '영어';
}
if (preg_match_all('!['.'\x{1100}-\x{11ff}\x{3130}-\x{318f}\x{ac00}-\x{d7af}'.']+!u', $str, $match))
{
        return '한글';
}
if (preg_match_all('!['.'\x{2E80}-\x{2EFF}'.'\x{31C0}-\x{31EF}\x{3200}-\x{32FF}'.'\x{3400}-\x{4DBF}\x{4E00}-\x{9FBF}\x{F900}-\x{FAFF}'.'\x{20000}-\x{2A6DF}\x{2F800}-\x{2FA1F}'.']+!u', $str, $match))
{
        return '한자';
}
if (preg_match_all('!['.'\x{2E80}-\x{2EFF}'.'\x{31C0}-\x{31EF}\x{3200}-\x{32FF}'.'\x{3400}-\x{4DBF}\x{4E00}-\x{9FBF}\x{F900}-\x{FAFF}'.'\x{20000}-\x{2A6DF}\x{2F800}-\x{2FA1F}'.']+!u', $str, $match))
{
        return '일어';
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s