Created
August 19, 2014 05:13
-
-
Save hlxwell/cf66dbab8c8b8c652099 to your computer and use it in GitHub Desktop.
Judge if string is Kana or not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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