Skip to content

Instantly share code, notes, and snippets.

@firedev
Last active August 29, 2015 14:14
Show Gist options
  • Save firedev/d347eeaa2b47225bdd37 to your computer and use it in GitHub Desktop.
Save firedev/d347eeaa2b47225bdd37 to your computer and use it in GitHub Desktop.
class TestCyrillic
class << self
def cyrillic?(string)
string[/\p{Cyrillic}/]
end
end
end
class String
def cyrillic?
TestCyrillic.cyrillic?(self)
end
end
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