case-insensitive

Make search in text file case-insensitive

戏子无情 提交于 2021-02-20 04:08:48
问题 I'm using the following function to search for words in a text file. The problem is that this function is case-sensitive. I don't want it to be case-sensitive! How can I make the function case-insensitive? $url = 'files/file.txt'; $thedata = file_get_contents($url); $lines = explode(PHP_EOL, $thedata); $search = 'some search words'; $pattern = preg_quote($search, '/'); $pattern = "/^.*$pattern.*\$/m"; if(preg_match_all($pattern, $thedata, $matches)) { echo implode('<br>', $matches[0]); } else

Make search in text file case-insensitive

孤街醉人 提交于 2021-02-20 04:08:01
问题 I'm using the following function to search for words in a text file. The problem is that this function is case-sensitive. I don't want it to be case-sensitive! How can I make the function case-insensitive? $url = 'files/file.txt'; $thedata = file_get_contents($url); $lines = explode(PHP_EOL, $thedata); $search = 'some search words'; $pattern = preg_quote($search, '/'); $pattern = "/^.*$pattern.*\$/m"; if(preg_match_all($pattern, $thedata, $matches)) { echo implode('<br>', $matches[0]); } else

Perform a Case insensitive Like query in a case sensitive SQL Server database

混江龙づ霸主 提交于 2021-02-07 13:38:55
问题 This is my scenario. SQL Server 2014 Standard edition, I have a database with a collation SQL_Latin1_General_CP437_BIN2 which is case sensitive. I want to perform a LIKE query which should return the output irrespective of case sensitive. Ex: if i execute a Like query to fetch the records with userName 'John' it should also return rows irrespective of case sensitive 'JOHN', 'John', 'john','joHN'. I tried using Lcase , Ucase , but I am getting the error Msg 195, Level 15, State 10, Line 4

Getting BeautifulSoup to catch tags in a non-case-sensitive way

人盡茶涼 提交于 2021-02-07 08:36:30
问题 I want to catch some tags with BeautifulSoup: Some <p> tags, the <title> tag, some <meta> tags. But I want to catch them regardless of their case; I know that some sites do meta like this: <META> and I want to be able to catch that. I noticed that BeautifulSoup is case-sensitive by default. How do I catch these tags in a non-case-sensitive way? 回答1: You can use soup.findAll which should match case-insensitively: import BeautifulSoup html = '''<html> <head> <meta name="description" content=

Getting BeautifulSoup to catch tags in a non-case-sensitive way

ぃ、小莉子 提交于 2021-02-07 08:35:58
问题 I want to catch some tags with BeautifulSoup: Some <p> tags, the <title> tag, some <meta> tags. But I want to catch them regardless of their case; I know that some sites do meta like this: <META> and I want to be able to catch that. I noticed that BeautifulSoup is case-sensitive by default. How do I catch these tags in a non-case-sensitive way? 回答1: You can use soup.findAll which should match case-insensitively: import BeautifulSoup html = '''<html> <head> <meta name="description" content=

How to make a CaseInsensitiveConcurrentMap?

倾然丶 夕夏残阳落幕 提交于 2021-02-04 17:14:47
问题 How can I implement class CaseInsensitiveConcurrentMap<V> implements ConcurrentMap<String , V> which works just like ConcurrentHashMap<String , V> except that the keys are compared case-insensitively? The keys should not be converted to lowercase or uppercase. Note that Collections.synchronizedMap(new TreeMap<String, new MyCaseInsensitiveComparator()) is no solution as it allows no concurrency and misses the additional methods. Creating a String-like class with case-insensitive equals and

Python case insensitive file name?

落爺英雄遲暮 提交于 2021-02-04 14:56:11
问题 I need to load a file given it's name, but the name I get is case insensitive. "A.txt" could actually be "a.txt". How to do this the fast way (not generate all possible names and try each)? 回答1: You could list the directory the file's in ( os.listdir ), and see if there are matches for your filename. The matching can be done by lower-casing both filenames and comparing. 回答2: You can't do it without taking a directory listing and taking both the item you're looking for and each in the

Gremlin case insensitive search

自作多情 提交于 2021-01-29 17:45:41
问题 I am new to Gremlin and I am using the Gremlin console to read data from a graph database. In the graph, there are vertices with label "Device". These vertices have a property "name" associated with them. I need to find out if there is a vertex that has a certain name. This check has to be case insensitive. Suppose I was to do this in a relational database, I could write the following query: SELECT * FROM device d WHERE LOWER(d.name) = 'mydevice' I am searching for a function similar to

How can I use automapper to map 2 enums that use different casing

我与影子孤独终老i 提交于 2021-01-28 20:33:18
问题 I have many enums that I want to keep all caps that I have to map to another system that has no standard at all (caps, no caps, pascal, camel). I can't find an automapper flag to tell it to ignore case for enums. I could use a custome converter for each enum but I would prefer a generic converter since there are so many. Some answers here have implied that automapper does this already. I don't get that from my testing. If I have these enums: public enum AllCaps { VALUE1, VALUE2, VALUE3 }

PHP Case-insensitive equivalent of strtr

随声附和 提交于 2021-01-28 03:44:45
问题 Where I could find a case-insensitive version of strtr ? strtr is overloaded, I am talking about the following one string strtr ( string $str , array $replace_pairs ) 回答1: Use str_ireplace: str_ireplace(array_keys($replace_pairs), array_values($replace_pairs), $str); 来源: https://stackoverflow.com/questions/7529330/php-case-insensitive-equivalent-of-strtr