case-insensitive

How to compare character ignoring case in primitive types

浪子不回头ぞ 提交于 2019-11-26 06:44:42
问题 I am writing these lines of code: String name1 = fname.getText().toString(); String name2 = sname.getText().toString(); aru = 0; count1 = name1.length(); count2 = name2.length(); for (i = 0; i < count1; i++) { for (j = 0; j < count2; j++) { if (name1.charAt(i)==name2.charAt(j)) aru++; } if(aru!=0) aru++; } I want to compare the Character s of two String s ignoring the case. Simply using IgnoreCase doesn\'t work. Adding \'65\' ASCII value doesn\'t work either. How do I do this? 回答1: The

SQL server ignore case in a where expression

血红的双手。 提交于 2019-11-26 06:26:57
问题 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 回答1: 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 =

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

白昼怎懂夜的黑 提交于 2019-11-26 05:53:08
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? cheduardo 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 can specify collate nocase when you

Why are functions and methods in PHP case-insensitive?

萝らか妹 提交于 2019-11-26 05:24:27
问题 Functions and methods in PHP are case-insensitive as illustrated in the following example. function ag() { echo \'2\'; } Ag(); class test { function clMe() { echo \'hi\'; } } $instance = new test; $instance->clme(); But that\'s the not case with variables. What\'s the rationale? 回答1: Let me quote from Interview – PHP’s Creator, Rasmus Lerdorf The first version of PHP was a simple set of tools that I put together for my Website and for a couple of projects. One tool did some fancy hit logging

CSS selector case insensitive for attributes

限于喜欢 提交于 2019-11-26 04:46:59
问题 If I have an HTML element <input type=\"submit\" value=\"Search\" /> a css selector needs to be case-sensitive: input[value=\'Search\'] matches input[value=\'search\'] does not match I need a solution where the case-insensitive approach works too. I am using Selenium 2 and Jquery , so answers for both are welcome. 回答1: It now exists in CSS4, see this answer. Otherwise, for jQuery, you can use... $(':input[name]').filter(function() { return this.value.toLowerCase() == 'search'; }); jsFiddle.

case-insensitive list sorting, without lowercasing the result?

风流意气都作罢 提交于 2019-11-26 04:45:01
问题 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. 回答1: In Python 3.3+ there is the str.casefold method that's specifically designed for caseless matching: sorted

Case insensitive string replacement in JavaScript?

限于喜欢 提交于 2019-11-26 04:19:44
问题 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

Case insensitive replace

怎甘沉沦 提交于 2019-11-26 03:51:58
问题 What\'s the easiest way to do a case-insensitive string replacement in Python? 回答1: The string type doesn't support this. You're probably best off using the regular expression sub method with the re.IGNORECASE option. >>> import re >>> insensitive_hippo = re.compile(re.escape('hippo'), re.IGNORECASE) >>> insensitive_hippo.sub('giraffe', 'I want a hIPpo for my birthday') 'I want a giraffe for my birthday' 回答2: import re pattern = re.compile("hello", re.IGNORECASE) pattern.sub("bye", "hello

Case-insensitive search in Rails model

折月煮酒 提交于 2019-11-26 03:27:41
问题 My product model contains some items Product.first => #<Product id: 10, name: \"Blue jeans\" > I\'m now importing some product parameters from another dataset, but there are inconsistencies in the spelling of the names. For instance, in the other dataset, Blue jeans could be spelled Blue Jeans . I wanted to Product.find_or_create_by_name(\"Blue Jeans\") , but this will create a new product, almost identical to the first. What are my options if I want to find and compare the lowercased name.

MongoDB: Is it possible to make a case-insensitive query?

梦想的初衷 提交于 2019-11-26 03:14:21
问题 Example: > db.stuff.save({\"foo\":\"bar\"}); > db.stuff.find({\"foo\":\"bar\"}).count(); 1 > db.stuff.find({\"foo\":\"BAR\"}).count(); 0 回答1: 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 maybe use-cases like tags. 回答2: UPDATE: The original answer