case-insensitive

Case insensitive 'in' - Python

拈花ヽ惹草 提交于 2019-11-26 03:09:17
问题 I love using the expression if \'MICHAEL89\' in USERNAMES: ... where USERNAMES is a list Is there any way to match items with case insensitivity or do I need to use a custom method? Just wondering if there is need to write extra code for this. Thanks to everyone! 回答1: if 'MICHAEL89' in (name.upper() for name in USERNAMES): ... Alternatively: if 'MICHAEL89' in map(str.upper, USERNAMES): ... Or, yes, you can make a custom method. 回答2: I would make a wrapper so you can be non-invasive. Minimally

Case insensitive string as HashMap key

断了今生、忘了曾经 提交于 2019-11-26 03:07:52
问题 I would like to use case insensitive string as a HashMap key for the following reasons. During initialization, my program creates HashMap with user defined String While processing an event (network traffic in my case), I might received String in a different case but I should be able to locate the <key, value> from HashMap ignoring the case I received from traffic. I\'ve followed this approach CaseInsensitiveString.java public final class CaseInsensitiveString { private String s; public

Case-insensitive search

不羁的心 提交于 2019-11-26 03:03:42
问题 I\'m trying to get a case-insensitive search with two strings in JavaScript working. Normally it would be like this: var string=\"Stackoverflow is the BEST\"; var result= string.search(/best/i); alert(result); The /i flag would be for case-insensitive. But I need to search for a second string; without the flag it works perfect: var string=\"Stackoverflow is the BEST\"; var searchstring=\"best\"; var result= string.search(searchstring); alert(result); If I add the /i flag to the above example

PHP & Case Sensitivity [duplicate]

纵饮孤独 提交于 2019-11-26 02:14:00
问题 This question already has answers here : Why are functions and methods in PHP case-insensitive? (2 answers) Closed 3 months ago . In PHP, variable and constant names are case sensitive, while function names are not. As far as I am aware, PHP is the only language in which this happens. All other languages I have used are either totally case sensitive or totally case insensitive. Why is PHP partially case senstive? Please note, that I am not asking which names are case sensitive, but why .

How to perform case-insensitive sorting in JavaScript?

大兔子大兔子 提交于 2019-11-26 01:57:59
问题 I have an array of strings I need to sort in JavaScript, but in a case-insensitive way. How to perform this? 回答1: In (almost :) a one-liner ["Foo", "bar"].sort(function (a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); }); Which results in [ 'bar', 'Foo' ] While ["Foo", "bar"].sort(); results in [ 'Foo', 'bar' ] 回答2: myArray.sort( function(a, b) { if (a.toLowerCase() < b.toLowerCase()) return -1; if (a.toLowerCase() > b.toLowerCase()) return 1; return 0; } ); EDIT: Please note

How to set Sqlite3 to be case insensitive when string comparing?

拈花ヽ惹草 提交于 2019-11-26 01:50:43
问题 I want to select records from sqlite3 database by string matching. But if I use \'=\' in the where clause, I found that sqlite3 is case sensitive. Can anyone tell me how to use string comparing case-insensitive? 回答1: 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

How can I search (case-insensitive) in a column using LIKE wildcard?

淺唱寂寞╮ 提交于 2019-11-26 01:45:00
问题 I looked around some and didn\'t find what I was after so here goes. SELECT * FROM trees WHERE trees.`title` LIKE \'%elm%\' This works fine, but not if the tree is named Elm or ELM etc... How do I make SQL case insensitive for this wild-card search? I\'m using MySQL 5 and Apache. 回答1: SELECT * FROM trees WHERE trees.`title` COLLATE UTF8_GENERAL_CI LIKE '%elm%' Actually, if you add COLLATE UTF8_GENERAL_CI to your column's definition, you can just omit all these tricks: it will work

How can I do a case insensitive string comparison?

南楼画角 提交于 2019-11-26 00:59:14
问题 How can I make the line below case insensitive? drUser[\"Enrolled\"] = (enrolledUsers.FindIndex(x => x.Username == (string)drUser[\"Username\"]) != -1); I was given some advice earlier today that suggested I use: x.Username.Equals((string)drUser[\"Username\"], StringComparison.OrdinalIgnoreCase))); the trouble is I can\'t get this to work, I\'ve tried the line below, this compiles but returns the wrong results, it returns enrolled users as unenrolled and unenrolled users as enrolled. drUser[\

How do I make jQuery Contains case insensitive, including jQuery 1.8+?

╄→гoц情女王★ 提交于 2019-11-26 00:23:58
问题 I\'m trying to use \"contains\" case insensitively. I tried using the solution at the following stackoverflow question, but it didn\'t work: Is there a case insensitive jQuery :contains selector? For convenience, the solution is copied here: jQuery.extend( jQuery.expr[\':\'], { Contains : \"jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0\" }); Here is the error: Error: q is not a function Source File: /js/jquery-1.4.js?ver=1.4 Line: 81 Here\'s where I\'m using it: $(\'input

Case insensitive searching in Oracle

北慕城南 提交于 2019-11-25 23:52:36
问题 The default behaviour of LIKE and the other comparison operators, = etc is case-sensitive. Is it possible make them case-insensitive? 回答1: Since 10gR2, Oracle allows to fine-tune the behaviour of string comparisons by setting the NLS_COMP and NLS_SORT session parameters: SQL> SET HEADING OFF SQL> SELECT * 2 FROM NLS_SESSION_PARAMETERS 3 WHERE PARAMETER IN ('NLS_COMP', 'NLS_SORT'); NLS_SORT BINARY NLS_COMP BINARY SQL> SQL> SELECT CASE WHEN 'abc'='ABC' THEN 1 ELSE 0 END AS GOT_MATCH 2 FROM DUAL