Last active
August 29, 2015 14:14
-
-
Save firedev/d347eeaa2b47225bdd37 to your computer and use it in GitHub Desktop.
String.cyrillic? http://memo.undr.su/2011/11/04/proverka-na-russkie-simvoly-v-stroke/
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 TestCyrillic | |
class << self | |
def cyrillic?(string) | |
string[/\p{Cyrillic}/] | |
end | |
end | |
end | |
class String | |
def cyrillic? | |
TestCyrillic.cyrillic?(self) | |
end | |
end |
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
raise unless "Русские буквы".cyrillic? # true | |
raise unless "Русские буквы и !№%:,.;()_+=-0986654".cyrillic? # true | |
raise unless "Русские буквы и English letters".cyrillic? # true <- was false | |
raise if "!№%:,.;()_+=-0986654".cyrillic? # false <- was true | |
raise if "Only English letters".cyrillic? # false | |
raise if "English letters and !№%:,.;()_+=-0986654".cyrillic? # false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment