In working with Japanese customers, i found useful regular expressions.
Regex for matching ALL Japanese common & uncommon Kanji (4e00
– 9fcf
) ~ The Big Kahuna!
1
/[一-龯]/
Regex for matching Hirgana or Katakana 1
1
/[ぁ-んァ-ン]/
Regex for matching Non-Hirgana or Non-Katakana
1
/[^ぁ-んァ-ン]/
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
1
/[ぁ-んァ-ン\w]/
Regex for matching Hirgana or Katakana and random other characters
1
/[ぁ-んァ-ン!:/]/
Regex for matching Hirgana
1
/[ぁ-ん]/
Regex for matching full-width Katakana (zenkaku 全角)
1
/[ァ-ン]/
Regex for matching half-width Katakana (hankaku 半角)
1
/[ァ-ン゙゚]/
Regex for matching full-width Numbers (zenkaku 全角)
1
/[0-9]/
Regex for matching full-width Letters (zenkaku 全角)
1
/[A-z]/
Regex for matching Hiragana codespace characters (includes non phonetic characters)
1
/[ぁ-ゞ]/
Regex for matching full-width (zenkaku) Katakana codespace characters (includes non phonetic characters)
1
/[ァ-ヶ]/
Regex for matching half-width (hankaku) Katakana codespace characters (this is an old character set so the order is inconsistent with the hiragana)
1
/[ヲ-゚]/
Regex for matching Japanese Post Codes
1
2
/^\d{3}-\d{4}$/
/^\d{3}-\d{4}$|^\d{3}-\d{2}$|^\d{3}$/
Regex for matching Japanese mobile phone numbers (keitai bangou)
1
2
/^\d{3}-\d{4}-\d{4}$|^\d{11}$/
/^0\d0-\d{4}-\d{4}$/
Regex for matching Japanese fixed line phone numbers
1
2
/^[0-9-]{6,9}$|^[0-9-]{12}$/
/^\d{1,4}-\d{4}$|^\d{2,5}-\d{1,4}-\d{4}$/
You can try in here: http://www.regexr.com/
Katakana without mentioning “full-width” or “half-width” means “full-width katakana”. ↩
Comments