How can I search (case-insensitive) in a column using LIKE wildcard?
I’ve always solved this using lower: SELECT * FROM trees WHERE LOWER( trees.title ) LIKE ‘%elm%’
I’ve always solved this using lower: SELECT * FROM trees WHERE LOWER( trees.title ) LIKE ‘%elm%’
You can use COLLATE NOCASE in your SELECT query: SELECT * FROM … WHERE name=”someone” COLLATE NOCASE Additionaly, in SQLite, you can indicate that a column should be case insensitive when you create the table by specifying collate nocase in the column definition (the other options are binary (the default) and rtrim; see here). You … Read more
This is what i’m using in a current project, haven’t had any problems. See if you have better luck with this format: jQuery.expr[‘:’].Contains = function(a, i, m) { return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0; }; In jQuery 1.8 the API for this changed, the jQuery 1.8+ version of this would be: jQuery.expr[“:”].Contains = jQuery.expr.createPseudo(function(arg) { return function( … Read more
Pass re.IGNORECASE to the flags param of search, match, or sub: re.search(‘test’, ‘TeSt’, re.IGNORECASE) re.match(‘test’, ‘TeSt’, re.IGNORECASE) re.sub(‘test’, ‘xxxx’, ‘Testing’, flags=re.IGNORECASE)
This is not the best practice in .NET framework (4 & +) to check equality String.Compare(x.Username, (string)drUser[“Username”], StringComparison.OrdinalIgnoreCase) == 0 Use the following instead String.Equals(x.Username, (string)drUser[“Username”], StringComparison.OrdinalIgnoreCase) MSDN recommends: Use an overload of the String.Equals method to test whether two strings are equal. Use the String.Compare and String.CompareTo methods to sort strings, not to check … Read more
There are 3 main ways to perform a case-insensitive search in Oracle without using full-text indexes. Ultimately what method you choose is dependent on your individual circumstances; the main thing to remember is that to improve performance you must index correctly for case-insensitive searching. 1. Case your column and your string identically. You can force … Read more
You could use a regex. In your example that would be: db.stuff.find( { foo: /^bar$/i } ); I must say, though, maybe you could just downcase (or upcase) the value on the way in rather than incurring the extra cost every time you find it. Obviously this wont work for people’s names and such, but … Read more
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
Identifiers (including column names) that are not double-quoted are folded to lowercase in PostgreSQL. Column names that were created with double-quotes and thereby retained uppercase letters (and/or other syntax violations) have to be double-quoted for the rest of their life: “first_Name” Values (string literals / constants) are enclosed in single quotes: ‘xyz’ So, yes, PostgreSQL … Read more
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