Contains case insensitive

Add .toUpperCase() after referrer. This method turns the string into an upper case string. Then, use .indexOf() using RAL instead of Ral. if (referrer.toUpperCase().indexOf(“RAL”) === -1) { The same can also be achieved using a Regular Expression (especially useful when you want to test against dynamic patterns): if (!/Ral/i.test(referrer)) { // ^i = Ignore case … Read more

How do I do a case-insensitive string comparison?

Assuming ASCII strings: string1 = ‘Hello’ string2 = ‘hello’ if string1.lower() == string2.lower(): print(“The strings are the same (case insensitive)”) else: print(“The strings are NOT the same (case insensitive)”) As of Python 3.3, casefold() is a better alternative: string1 = ‘Hello’ string2 = ‘hello’ if string1.casefold() == string2.casefold(): print(“The strings are the same (case insensitive)”) … Read more

Case insensitive ‘Contains(string)’

You could use the String.IndexOf Method and pass StringComparison.OrdinalIgnoreCase as the type of search to use: string title = “STRING”; bool contains = title.IndexOf(“string”, StringComparison.OrdinalIgnoreCase) >= 0; Even better is defining a new extension method for string: public static class StringExtensions { public static bool Contains(this string source, string toCheck, StringComparison comp) { return source?.IndexOf(toCheck, … Read more