Skip to content

Instantly share code, notes, and snippets.

@tricknotes
Created October 14, 2012 10:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tricknotes/3888158 to your computer and use it in GitHub Desktop.
Save tricknotes/3888158 to your computer and use it in GitHub Desktop.
JavaScript での全角・半角の正規表現
// see: http://gimite.net/gimite/rubymess/moji.html
var zenkaku = /(?:[ !”#$%&’()*+,-./:;<=>?@[¥]^_‘{|} ̄])|(?:[、。・゛゜´`¨ヽヾゝゞ〃仝々〆〇ー―‐\~〜∥…‥“〔〕〈〉《》「」『』【】±×÷≠≦≧∞∴♂♀°′″℃¢£§☆★○●◎◇◇◆□■△▲▽▼※〒→←↑↓〓])|(?:[0-9])|(?:[A-Z])|(?:[a-z])|(?:[ぁ-ん])|(?:[ァ-ヶ])|(?:[Α-Ωα-ω])|(?:[А-Яа-я])|(?:[\u2570-\u25ff])|(?:[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/;
var hankaku = /(?:[\x00-\x1f\x7f])|(?:[ !"#$%&'()*+,\-.\/:;<=>?@\[\\\]\^_`{|}~])|(?:[\uFF61\uFF62\uFF63\uFF64\uFF70\uFF9E\uFF9F\uFF65])|(?:[0-9])|(?:[A-Z])|(?:[a-z])|(?:[\uFF66-\uFF6F\uFF71-\uFF9D])/;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment