case-insensitive

How can Python regex ignore case inside a part of a pattern but not the entire expression?

心不动则不痛 提交于 2019-11-30 19:59:46
Say I have a string containing foobar fooBAR FOObar FOOBAR , and I want to search all instances containing a case insensitive "foo" or "FOO" but a lowercase "bar". In this case, re.findall should return ['foobar', 'FOObar'] . The accepted answer for this question explains that it can be done in C# with (?i)foo(?-i)bar , but Python raises an invalid expression error. Does the Python regex library support such a feature? The re module doesn't support scoped flags, but there's an alternative regex implementation which does: http://pypi.python.org/pypi/regex Python does not support disabling flags

.NET How to compare two Strings that represent filenames ignoring case correctly

时光毁灭记忆、已成空白 提交于 2019-11-30 17:19:41
Given that (at least on NTFS) the filesystem on Windows is case insensitive, I would like to compare String fileA to String fileB as such: fileA.Equals(fileB, StringComparison.CurrentCultureIgnoreCase) The question then becomes which culture I should use, does the default current (ui?) culture suffice? I can't seem to find any BCL methods for this purpose. Guffa You should use StringComparison.OrdinalIgnoreCase , as is detailed in Best Practices for Using Strings in the .NET Framework (search for "file paths" to find the relevant section). If you use a culture for matching the strings, you may

How do I ignore case when using startsWith and endsWith in Java? [duplicate]

送分小仙女□ 提交于 2019-11-30 17:00:01
This question already has an answer here: startsWith() method of string ignoring case 7 answers Here's my code: public static void rightSel(Scanner scanner,char t) { /*if (!stopping)*/System.out.print(": "); if (scanner.hasNextLine()) { String orInput = scanner.nextLine; if (orInput.equalsIgnoreCase("help") { System.out.println("The following commands are available:"); System.out.println(" 'help' : displays this menu"); System.out.println(" 'stop' : stops the program"); System.out.println(" 'topleft' : makes right triangle alligned left and to the top"); System.out.println(" 'topright' : makes

How to do case insensitive search in Vim

我的未来我决定 提交于 2019-11-30 10:02:02
问题 I'd like to search for an upper case word, for example COPYRIGHT in a file. I tried performing a search like: /copyright/i # Doesn't work but it doesn't work. I know that in Perl, if I give the i flag into a regex it will turn the regex into a case-insensitive regex. It seems that Vim has its own way to indicate a case-insensitive regex. 回答1: You need to use the \c escape sequence. So: /\ccopyright To do the inverse (case sensitive matching), use \C instead. 回答2: As well as the suggestions

ORACLE 11g case insensitive by default

非 Y 不嫁゛ 提交于 2019-11-30 08:44:10
问题 I found in this article, that since ORACLE 10g, there is a way to make a particular connection-session compare strings case-insensitive, without needing any crazy SQL functions, using an ALTER SESSION . Does anyone know if, in 11g, there might be a way to make the database to always operate in this mode by default for all new connection-sessions, thereby eliminating the need for running ALTER SESSION s every time you connect? Or perhaps, an additional parameter you could specify on your

Using InvariantCultureIgnoreCase instead of ToUpper for case-insensitive string comparisons

荒凉一梦 提交于 2019-11-30 06:57:14
问题 On this page, a commenter writes: Do NOT ever use .ToUpper to insure comparing strings is case-insensitive. Instead of this: type.Name.ToUpper() == (controllerName.ToUpper() + "Controller".ToUpper())) Do this: type.Name.Equals(controllerName + "Controller", StringComparison.InvariantCultureIgnoreCase) Why is this way preferred? 回答1: Here is the answer in details .. The Turkey Test ( read section 3 ) As discussed by lots and lots of people, the "I" in Turkish behaves differently than in most

Running a case-insensitive cypher query

[亡魂溺海] 提交于 2019-11-30 06:43:02
问题 Is it possible to run a case-insensitive cypher query on neo4j? Try that: http://console.neo4j.org/ When I type into this: start n=node(*) match n-[]->m where (m.name="Neo") return m it returns one row. But when I type into this: start n=node(*) match n-[]->m where (m.name="neo") return m it does not return anything; because the name is saved as "Neo". Is there a simple way to run case-insensitive queries? 回答1: Yes, by using case insensitive regular expressions: WHERE m.name =~ '(?i)neo' http

Javascript: highlight substring keeping original case but searching in case insensitive mode

人盡茶涼 提交于 2019-11-30 06:25:04
问题 I'm trying to write a "suggestion search box" and I cannot find a solution that allows to highlight a substring with javascript keeping the original case. For example if I search for " ca " I search server side in a case insensitive mode and I have the following results: Calculator calendar ESCAPE I would like to view the search string in all the previous words, so the result should be: Ca lculator ca lendar ES CA PE I tried with the following code: var reg = new RegExp(querystr, 'gi'); var

How to compare strings with case insensitive and accent insensitive

為{幸葍}努か 提交于 2019-11-30 03:58:14
问题 How to compare strings with case insensitive and accent insensitive Alright this is done easily at SQL server However I would like to do the same at C# .NET 4.5.1. How can I do that with most proper way? I mean these 3 strings should return equal when compared http://www.buroteknik.com/metylan-c387c4b0ft-tarafli-bant-12cm-x25mt_154202.html http://www.buroteknik.com/METYLAN-C387C4B0FT-TARAFLI-BANT-12cm-x25mt_154202.html http://www.buroteknik.com/METYLAN-C387C4B0FT-TARAFLı-BANT-12cm-x25mt

Case insensitive string search in golang

僤鯓⒐⒋嵵緔 提交于 2019-11-30 03:00:26
How do I search through a file for a word in a case insensitive manner? For example If I'm searching for UpdaTe in the file, if the file contains update, the search should pick it and count it as a match. strings.EqualFold() can check if two strings are equal, while ignoring case. It even works with Unicode. See http://golang.org/pkg/strings/#EqualFold for more info. http://play.golang.org/p/KDdIi8c3Ar package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.EqualFold("HELLO", "hello")) fmt.Println(strings.EqualFold("ÑOÑO", "ñoño")) } Both return true. Presumably the important