Skip to content

Instantly share code, notes, and snippets.

@ryanmcgrath
Forked from sym3tri/JapaneseRegex.js
Last active March 22, 2025 05:58

Revisions

  1. ryanmcgrath revised this gist Dec 20, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JapaneseRegex.js
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@
    // 2190-2195 : Arrows
    // u203B : Weird asterisk thing

    var regex = /[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g;
    var regex = /[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/;
    var input = "input string";
    if(regex.test(input)) {
    console.log("Japanese characters found")
  2. @sym3tri sym3tri created this gist May 19, 2011.
    29 changes: 29 additions & 0 deletions JapaneseRegex.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    // REFERENCE UNICODE TABLES:
    // http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml
    // http://www.tamasoft.co.jp/en/general-info/unicode.html
    //
    // TEST EDITOR:
    // http://www.gethifi.com/tools/regex
    //
    // UNICODE RANGE : DESCRIPTION
    //
    // 3000-303F : punctuation
    // 3040-309F : hiragana
    // 30A0-30FF : katakana
    // FF00-FFEF : Full-width roman + half-width katakana
    // 4E00-9FAF : Common and uncommon kanji
    //
    // Non-Japanese punctuation/formatting characters commonly used in Japanese text
    // 2605-2606 : Stars
    // 2190-2195 : Arrows
    // u203B : Weird asterisk thing

    var regex = /[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g;
    var input = "input string";
    if(regex.test(input)) {
    console.log("Japanese characters found")
    }
    else {
    console.log("No Japanese characters");
    }