Skip to content

Instantly share code, notes, and snippets.

@hlxwell
Created August 19, 2014 05:13
Show Gist options
  • Save hlxwell/cf66dbab8c8b8c652099 to your computer and use it in GitHub Desktop.
Save hlxwell/cf66dbab8c8b8c652099 to your computer and use it in GitHub Desktop.
Judge if string is Kana or not.
class String
def is_katakana?
(self =~ /^[゠-ヿ -〿]+$/) == 0
end
def is_half_katakana?
(self =~ /^[⦅-゚ -〿]+$/) == 0
end
def is_hiragana?
(self =~ /^[ぁ-ゟ -〿]+$/) == 0
end
def is_kanji?
(self =~ /^[一-龯 -〿]+$/) == 0
end
def is_kana?
(self =~ /^[゠-ヿ⦅-゚ぁ-ゟ一-龯 -〿]+$/) == 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment