How to compare strings ignoring the case

You’re looking for casecmp. It returns 0 if two strings are equal, case-insensitively.

str1.casecmp(str2) == 0

"Apple".casecmp("APPLE") == 0
#=> true

Alternatively, you can convert both strings to lower case (str.downcase) and compare for equality.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)