case-insensitive

Case insensitive search in Mongo

百般思念 提交于 2019-12-17 15:39:44
问题 I am using a case insensitive search in Mongo, something similar to https://stackoverflow.com/q/5500823/1028488. ie I am using a regex with options i. But I am am having trouble restricting the regex to just that word, its performs more like a 'Like' in SQL eg: if I use query like {"SearchWord" : { '$regex' : 'win', $options: '-i' }} , it shows me results for win, window & winter. How do i restrict it to jsut show win? I tried /^win$/ but its sayin invalid Json.... Please suggest a way.

How can I make the map::find operation case insensitive?

一笑奈何 提交于 2019-12-17 08:23:12
问题 Does the map::find method support case insensitive search? I have a map as follows: map<string, vector<string> > directory; and want the below search to ignore case: directory.find(search_string); 回答1: It does not by default. You will have to provide a custom comparator as a third argument. Following snippet will help you... /************************************************************************/ /* Comparator for case-insensitive comparison in STL assos. containers */ /********************

How to change MySQL table names in Linux server to be case insensitive?

夙愿已清 提交于 2019-12-17 07:33:18
问题 I'm working on an old website that used to be hosted on an Apple server. When it was migrated into a new Linux server it stopped working. I'm pretty sure it's because all the MySQL queries used in the php scripts have different case combinations for the table names (I don't know why the original developers didn't follow any conventions when they created the table names or the php scripts) and it didn't matter because both Mac and Windows MySQL servers are case insensitive by default when it

Is there a C# case insensitive equals operator?

醉酒当歌 提交于 2019-12-17 03:49:58
问题 I know that the following is case sensitive: if (StringA == StringB) { So is there an operator which will compare two strings in an insensitive manner? 回答1: Try this: string.Equals(a, b, StringComparison.CurrentCultureIgnoreCase); 回答2: The best way to compare 2 strings ignoring the case of the letters is to use the String.Equals static method specifying an ordinal ignore case string comparison. This is also the fastest way, much faster than converting the strings to lower or upper case and

How to replace case-insensitive literal substrings in Java

空扰寡人 提交于 2019-12-17 02:28:42
问题 Using the method replace(CharSequence target, CharSequence replacement) in String, how can I make the target case-insensitive? For example, the way it works right now: String target = "FooBar"; target.replace("Foo", "") // would return "Bar" String target = "fooBar"; target.replace("Foo", "") // would return "fooBar" How can I make it so replace (or if there is a more suitable method) is case-insensitive so that both examples return "Bar"? 回答1: String target = "FOOBar"; target = target

Contains case insensitive

廉价感情. 提交于 2019-12-17 02:19:07
问题 I have the following: if (referrer.indexOf("Ral") == -1) { ... } What I like to do is to make Ral case insensitive, so that it can be RAl , rAl , etc. and still match. Is there a way to say that Ral has to be case-insensitive? 回答1: Add .toLowerCase() after referrer . This method turns the string in a lower case string. Then, use .indexOf() using ral instead of Ral . if (referrer.toLowerCase().indexOf("ral") === -1) { The same can also be achieved using a Regular Expression (especially useful

Case insensitive regular expression without re.compile?

百般思念 提交于 2019-12-17 01:35:56
问题 In Python, I can compile a regular expression to be case-insensitive using re.compile : >>> s = 'TeSt' >>> casesensitive = re.compile('test') >>> ignorecase = re.compile('test', re.IGNORECASE) >>> >>> print casesensitive.match(s) None >>> print ignorecase.match(s) <_sre.SRE_Match object at 0x02F0B608> Is there a way to do the same, but without using re.compile . I can't find anything like Perl's i suffix (e.g. m/test/i ) in the documentation. 回答1: Pass re.IGNORECASE to the flags param of

Perl : Get array of all possible cases of a string

大城市里の小女人 提交于 2019-12-13 22:42:06
问题 I need to get an array of all possible cases of a string. Like it's written here: Combination of all possible cases of a string How do I do that in Perl efficiently? I want something like this: print "$_\n" for GetCases('perl'); # Output: perl Perl ... pERl ... PERL Note I tagged glob because it's the function to which I want to feed the result, so people as me will later find the question. However, The question is not only about this particular case of usage. Related question : Should I

How to return a result from JSON with case insensitive search using javascript?

和自甴很熟 提交于 2019-12-13 19:39:07
问题 My JSON contains 'products' that each have multiple values (name, manufacturer etc.) I have the following code that allows me to pull 'products' from my JSON based on a search result acquired from a query string. It works fine, but only if the search entry is formatted exactly how it is written in the string. How can I allow case insensitive searches yield the desired result (and ideally, partial searches)? I believe that regular expressions are the way to go, but I've exhausted my knowledge

Case insensitive

家住魔仙堡 提交于 2019-12-13 13:07:26
问题 If TextBox2.Text = "a" AndAlso TextBox21.Text = "a" Then 'MessageBox.Show("A") totCorrect = totCorrect + corAns ElseIf TextBox2.Text = "b" AndAlso TextBox21.Text = "b" Then 'MessageBox.Show("B") totCorrect = totCorrect + corAns ElseIf TextBox2.Text = "c" AndAlso TextBox21.Text = "c" Then 'MessageBox.Show("C") totCorrect = totCorrect + corAns ElseIf TextBox2.Text = "d" AndAlso TextBox21.Text = "d" Then 'MessageBox.Show("D") totCorrect = totCorrect + corAns Else totWrong = totWrong + wrgAns