case-insensitive

SQL server ignore case in a where expression

不羁的心 提交于 2019-11-26 19:44:29
How do I construct a SQL query (MS SQL Server) where the "where" clause is case-insensitive? SELECT * FROM myTable WHERE myField = 'sOmeVal' I want the results to come back ignoring the case In the default configuration of a SQL Server database, string comparisons are case-insensitive. If your database overrides this setting (through the use of an alternate collation), then you'll need to specify what sort of collation to use in your query. SELECT * FROM myTable WHERE myField = 'sOmeVal' COLLATE SQL_Latin1_General_CP1_CI_AS Note that the collation I provided is just an example (though it will

PostgreSQL: Case insensitive string comparison

放肆的年华 提交于 2019-11-26 19:26:41
问题 Is there a simple ignore-case-comparison for PostgreSQL? I want to replace: SELECT id, user_name FROM users WHERE lower(email) IN (lower('adamB@a.com'), lower('eveA@b.com')); With something like: SELECT id, user_name FROM users WHERE email IGNORE_CASE_IN ('adamB@a.com', 'eveA@b.com'); The like and ilike operators work on single values (e.g. like 'adamB@a.com' ), but not on sets. 回答1: First, what not to do, don't use ilike... create table y ( id serial not null, email text not null unique );

django-orm case-insensitive order by

丶灬走出姿态 提交于 2019-11-26 18:13:40
问题 I know, I can run a case insensitive search from DJango ORM. Like, User.objects.filter(first_name__contains="jake") User.objects.filter(first_name__contains="sulley") User.objects.filter(first_name__icontains="Jake") User.objects.filter(first_name__icontains="Sulley") And also, I can fetch them as user_list = User.objects.all().order_by("first_name") # sequence: (Jake, Sulley, jake, sulley) user_list = User.objects.all().order_by("-first_name") # for reverse # sequence: (sulley, jake, Sulley,

Can PHP's glob() be made to find files in a case insensitive manner?

半腔热情 提交于 2019-11-26 17:28:45
问题 I want all CSV files in a directory, so I use glob('my/dir/*.CSV') This however doesn't find files with a lowercase CSV extension. I could use glob('my/dir/*.{CSV,csv}', GLOB_BRACE); But is there a way to allow all mixed case versions? Or is this just a limitation of glob() ? 回答1: Glob patterns support character ranges: glob('my/dir/*.[cC][sS][vV]') 回答2: You could do this $files = glob('my/dir/*'); $csvFiles = preg_grep('/\.csv$/i', $files); 回答3: glob('my/dir/*.[cC][sS][vV]') should do it.

Case insensitive std::string.find()

安稳与你 提交于 2019-11-26 17:27:50
问题 I am using std::string 's find() method to test if a string is a substring of another. Now I need case insensitive version of the same thing. For string comparison I can always turn to stricmp() but there doesn't seem to be a stristr() . I have found various answers and most suggest using Boost which is not an option in my case. Additionally, I need to support std::wstring / wchar_t . Any ideas? 回答1: You could use std::search with a custom predicate. #include <locale> #include <iostream>

Case insensitive comparison of strings in shell script

旧城冷巷雨未停 提交于 2019-11-26 17:27:34
问题 The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this? 回答1: if you have bash str1="MATCH" str2="match" shopt -s nocasematch case "$str1" in $str2 ) echo "match";; *) echo "no match";; esac otherwise, you should tell us what shell you are using. alternative, using awk str1="MATCH" str2="match" awk -vs1="$str1" -vs2="$str2" 'BEGIN { if ( tolower(s1) == tolower(s2) ){ print

Underscore.js Case Insensitive Sorting

柔情痞子 提交于 2019-11-26 17:22:25
问题 Having some slight issues trying to get underscore.js to do case-insensitive sorting. I have an array of objects and would like to be able to sort by property name. Using shortcut method sortBy iteratee may also be the string name of the property to sort by (eg. length). Array to be sorted: var array = [{ name: 'test_1234', description: 'zzaaa bb cc'}, { name: 'zz1111', description: 'ZAAbbbcc'}, { name: 'TEST', description: '4422'}, { name: '1a2929', description: 'abcdef'}, { name: 'abc',

SelectNodes with XPath ignoring cases

这一生的挚爱 提交于 2019-11-26 17:12:53
问题 I have a problem finding elements in XPath that's contains a certain string ignoring character casing. I want to find in a HTML page all the nodes with id contains the text "footer" ignoring it's write in uppercase or lowercase. In my example I have a different html text like this: <div id="footer">some text</div> <div id="anotherfooter">some text</div> <div id="AnotherFooter">some text</div> <div id="AnotherFooterAgain">some text</div> I need to select all nodes (or any combination in any

case-insensitive list sorting, without lowercasing the result?

戏子无情 提交于 2019-11-26 16:13:56
I have a list of strings like this: ['Aden', 'abel'] I want to sort the items, case-insensitive. So I want to get: ['abel', 'Aden'] But I get the opposite with sorted() or list.sort() , because uppercase appears before lowercase. How can I ignore the case? I've seen solutions which involves lowercasing all list items, but I don't want to change the case of the list items. The following works in Python 2: sorted_list = sorted(unsorted_list, key=lambda s: s.lower()) It works for both normal and unicode strings, since they both have a lower method. In Python 2 it works for a mix of normal and

Case insensitive string replacement in JavaScript?

本秂侑毒 提交于 2019-11-26 15:19:18
I need to highlight, case insensitively, given keywords in a JavaScript string. For example: highlight("foobar Foo bar FOO", "foo") should return "<b>foo</b>bar <b>Foo</b> bar <b>FOO</b>" I need the code to work for any keyword, and therefore using a hardcoded regular expression like /foo/i is not a sufficient solution. What is the easiest way to do this? (This an instance of a more general problem detailed in the title, but I feel that it's best to tackle with a concrete, useful example.) okoman You can use regular expressions if you prepare the search string. In PHP e.g. there is a function