case-insensitive

How do I do a case-insensitive string comparison?

情到浓时终转凉″ 提交于 2019-11-25 22:24:07
问题 How can I do case insensitive string comparison in Python? I would like to encapsulate comparison of a regular strings to a repository string using in a very simple and Pythonic way. I also would like to have ability to look up values in a dict hashed by strings using regular python strings. 回答1: Assuming ASCII strings: string1 = 'Hello' string2 = 'hello' if string1.lower() == string2.lower(): print("The strings are the same (case insensitive)") else: print("The strings are NOT the same (case

Are PostgreSQL column names case-sensitive?

风流意气都作罢 提交于 2019-11-25 22:18:06
问题 I have a db table say, persons in Postgres handed down by another team that has a column name say, \"first_Name\" . Now am trying to use PG commander to query this table on this column-name. select * from persons where first_Name=\"xyz\"; And it just returns ERROR: column \"first_Name\" does not exist Not sure if I am doing something silly or is there a workaround to this problem that I am missing? 回答1: All identifiers (including column names) that are not double-quoted are folded to lower

How can I do a case insensitive string comparison?

こ雲淡風輕ζ 提交于 2019-11-25 21:46: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["Enrolled"] = (enrolledUsers.FindIndex(x => x.Username.Equals((string)drUser["Username"], StringComparison

Case insensitive 'Contains(string)'

可紊 提交于 2019-11-25 21:38:09
问题 Is there a way to make the following return true? string title = \"ASTRINGTOTEST\"; title.Contains(\"string\"); There doesn\'t seem to be an overload that allows me to set the case sensitivity.. Currently I UPPERCASE them both, but that\'s just silly (by which I am referring to the i18n issues that come with up- and down casing). UPDATE This question is ancient and since then I have realized I asked for a simple answer for a really vast and difficult topic if you care to investigate it fully.

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

狂风中的少年 提交于 2019-11-25 18:42:33
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. Quassnoi 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 automatically. ALTER TABLE trees MODIFY COLUMN title VARCHAR(…) CHARACTER SET UTF8 COLLATE UTF8_GENERAL_CI. This