Skip to content

Instantly share code, notes, and snippets.

@dvdantunes
Forked from terrancesnyder/regex-japanese.txt
Last active November 14, 2023 02:22
Show Gist options
  • Save dvdantunes/f58baff56d45a53dbe4c0a22a72624e7 to your computer and use it in GitHub Desktop.
Save dvdantunes/f58baff56d45a53dbe4c0a22a72624e7 to your computer and use it in GitHub Desktop.
Regex for Japanese

Regex Japanese

Reference


From "Japanese Regex Alzheimers – Why Can't I Remember?"

URL: On wayback machine

Match Example Regex
ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna! ([一-龯])
Hiragana or Katakana ([ぁ-んァ-ン])
non-Hiragana or non-Katakana ([^ぁ-んァ-ン])
Hiragana or Katakana or basic punctuation (、。’) ([ぁ-んァ-ン\w])

Regex for matching Hirgana or Katakana or basic punctuation (、。’) ([ぁ-んァ-ン\w])

Regex for matching Hirgana or Katakana and random other characters ([ぁ-んァ-ン!:/])

Regex for matching Hirgana ([ぁ-ん])

Regex for matching full-width Katakana (zenkaku 全角) ([ァ-ン])

Regex for matching half-width Katakana (hankaku 半角) ([ァ-ン゙゚])

Regex for matching full-width Numbers (zenkaku 全角) ([0-9])

Regex for matching full-width Letters (zenkaku 全角) ([A-z])

Regex for matching Hiragana codespace characters (includes non phonetic characters) ([ぁ-ゞ])

Regex for matching full-width (zenkaku) Katakana codespace characters (includes non phonetic characters) ([ァ-ヶ])

Regex for matching half-width (hankaku) Katakana codespace characters (this is an old character set so the order is inconsistent with the hiragana) ([ヲ-゚])

Regex for matching Japanese Post Codes /^¥d{3}¥-¥d{4}$/ /^¥d{3}-¥d{4}$|^¥d{3}-¥d{2}$|^¥d{3}$/

Regex for matching Japanese mobile phone numbers (keitai bangou) /^¥d{3}-¥d{4}-¥d{4}$|^¥d{11}$/ /^0¥d0-¥d{4}-¥d{4}$/

Regex for matching Japanese fixed line phone numbers /^[0-9-]{6,9}$|^[0-9-]{12}$/ /^¥d{1,4}-¥d{4}$|^¥d{2,5}-¥d{1,4}-¥d{4}$/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment