case-insensitive

Anyone had success using a specific locale for a PostgreSQL database so that text comparison is case-insensitive?

喜你入骨 提交于 2019-12-05 08:53:14
I'm developing an app in Rails on OS X using PostgreSQL 8.4. I need to setup the database for the app so that standard text queries are case-insensitive. For example: SELECT * FROM documents WHERE title = 'incredible document' should return the same result as: SELECT * FROM documents WHERE title = 'Incredible Document' Just to be clear, I don't want to use: (1) LIKE in the where clause or any other type of special comparison operators (2) citext for the column datatype or any other special column index (3) any type of full-text software like Sphinx What I do want is to set the database locale

Case insensitive compare against bunch of strings

梦想的初衷 提交于 2019-12-05 04:32:01
问题 What would be the best method to compare an NSString to a bunch of other strings case insensitive? If it is one of the strings then the method should return YES, otherwise NO. 回答1: Here's a little helper function: BOOL isContainedIn(NSArray* bunchOfStrings, NSString* stringToCheck) { for (NSString* string in bunchOfStrings) { if ([string caseInsensitiveCompare:stringToCheck] == NSOrderedSame) return YES; } return NO; } Of course this could be greatly optimized for different use cases. If, for

MongoDB: how to find documents ignoring case sensitive, accents and percent like logic (%)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 01:16:18
问题 I would like to make a search on a collection in my mongodb database. In my collection, I have documents with the field "name" can be values like: [i] "Palácio Guanabara", "Palácio da Cidade", "Festa Palácio", etc. When a user types a search like "pala" or "palá" or "Pala" or "PalÁ", all those itens in [i] must build the result set. I found that in MongoDB I could use regex in searches, like: { "name": { $regex: new Regex(".*pala.*", "i") } } Ok, this approach is case insensitive and use the

PostgreSQL case insensitive SELECT on array

喜欢而已 提交于 2019-12-04 22:31:36
I'm having problems finding the answer here, on google or in the docs ... I need to do a case insensitive select against an array type. So if: value = {"Foo","bar","bAz"} I need SELECT value FROM table WHERE 'foo' = ANY(value) to match. I've tried lots of combinations of lower() with no success. ILIKE instead of = seems to work but I've always been nervous about LIKE - is that the best way? Craig Ringer One alternative not mentioned is to install the citext extension that comes with PostgreSQL 8.4+ and use an array of citext : regress=# CREATE EXTENSION citext; regress=# SELECT 'foo' = ANY( '{

Open a file case-insensitively in Ruby under Linux

人盡茶涼 提交于 2019-12-04 18:16:23
问题 Is there a way to open a file case-insensitively in Ruby under Linux? For example, given the string foo.txt , can I open the file FOO.txt ? One possible way would be reading all the filenames in the directory and manually search the list for the required file, but I'm looking for a more direct method. 回答1: Whilst you can't make open case insensitive you can write the directory search you suggested quite concisely. e.g. filename = Dir.glob('foo.txt', File::FNM_CASEFOLD).first if filename # use

Assuming Unicode and case-insensitivity, should the pattern “..” match “FfIsS”?

牧云@^-^@ 提交于 2019-12-04 16:09:32
问题 It sounds like a joke, but I can sort of prove it. Assumptions: Dot matches any single character. A case-insensitive pattern matches s if and only if it matches s.toUpperCase() . All of the following is pretty logical and holds in Java: "ffi".matches(".") LATIN SMALL LIGATURE FFI (U+FB03) is a character, so it must match "ß".matches(".") LATIN SMALL LETTER SHARP S (U+00DF) is a character, so it must match "ffi".toUpperCase().equals("FFI") by the Unicode standard (there's no capital ligature FFI)

What is the most efficient case-insensitive grep usage?

蹲街弑〆低调 提交于 2019-12-04 15:00:45
问题 My objective is to match email addresses that belong to the Yahoo! family of domains. In *nix systems (I will be using Ubuntu), what are the benefits and drawbacks to any one of these methods for matching the pattern? And if there is another, more elegant solution that I haven't been capable of imagining, please share. Here they are: Use grep with option -i : grep -Ei "@(yahoo|(y|rocket)mail|geocities)\.com" Translate characters to all upper case or lower case then grep : tr [:upper:] [:lower

Make Folders in Apache Case Insensitive using .htaccess

故事扮演 提交于 2019-12-04 12:30:23
I need to make accessing directories on my server case insensitive. How do I do that using htaccess? You have to install and enable the mod_speling module in apache and set the CheckCaseOnly Directive to On in your .htaccess CheckCaseOnly On If you want requested URLs to be valid whether uppercase or lowercase letters are used, use mod_speling to make URLs case-insensitive. Write the following code in .htaccess file: CheckSpelling On This is what I used because my hosting is shared and does not include the mod_spelling module but does support .htaccess, but this only works for one folder:

Find possible duplicates in two columns ignoring case and special characters

元气小坏坏 提交于 2019-12-04 11:37:31
问题 Query SELECT COUNT(*), name, number FROM tbl GROUP BY name, number HAVING COUNT(*) > 1 It sometimes fails to find duplicates between lower case and upper case. E.g.: sunny and Sunny don't show up as a duplicates. So how to find all possible duplicates in PostgreSQL for two columns. 回答1: lower()/ upper() Use one of these to fold characters to either lower or upper case. Special characters are not affected: SELECT count(*), lower(name), number FROM tbl GROUP BY lower(name), number HAVING count(

Case Sensitivity Kotlin / ignoreCase

五迷三道 提交于 2019-12-04 05:22:16
I am trying to ignore case sensitivity on a string. For example, a user can put "Brazil" or "brasil" and the fun will trigger. How do I implement this? I am new to Kotlin. fun questionFour() { val edittextCountry = findViewById<EditText>(R.id.editTextCountry) val answerEditText = edittextCountry.getText().toString() if (answerEditText == "Brazil") { correctAnswers++ } if (answerEditText == "Brasil") { correctAnswers++ } } EDIT Another person helped me write like this. My question now about this way is "Is there a cleaner way to write this?" fun questionFour() { val edittextCountry =