Reputation: 2343
Let's say I have multiple strings. Those strings could contain german umlauts like ö,ä,ü,Ü,ß...
Id like to check if my strings have umlauts in them, e.g:
has_umlaut(string) # should return true or false
"BG Göttingen" -> true
"BV Chemnitz 99" -> false
"Giants Düsseldorf" -> true
"Klöß" -> true
Hope somebody can help me out!
Upvotes: 3
Views: 1435
Reputation: 31653
You can use regexp:
def has_umlaut(str)
!!(str =~ /[öäüÖÄÜß]/)
end
Upvotes: 3