不區分大小寫的“包含(字串)” - Case insensitive 'Contains(string)'
問題:
Is there a way to make the following return true?有沒有辦法使以下返回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).似乎沒有允許我設定區分大小寫的過載.. 目前我將它們都大寫,但這只是愚蠢的(我指的是上下大小寫的i18n問題)。
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.這個問題很古老,從那時起我就意識到,如果您願意對一個非常龐大而困難的話題進行全面調查,我會要求一個簡單的答案。
For most cases, in mono-lingual, English code bases this answer will suffice.對於大多數情況,在單語、英語程式碼庫中,這個答案就足夠了。 I'm suspecting because most people coming here fall in this category this is the most popular answer.我懷疑是因為大多數來這裡的人都屬於這一類,這是最受歡迎的答案。
This answer however brings up the inherent problem that we can't compare text case insensitive until we know both texts are the same culture and we know what that culture is.然而,這個答案帶來了一個固有的問題,即在我們知道兩個文字是相同的文化並且我們知道該文化是什麼之前,我們無法比較不區分大小寫的文字。 This is maybe a less popular answer, but I think it is more correct and that's why I marked it as such.這可能是一個不太受歡迎的答案,但我認為它更正確,這就是我將其標記為這樣的原因。
解決方案:
參考一: http://stackoom.com/question/1riA參考二: Case insensitive 'Contains(string)'
- Java - 無法訪問 Foo 型別的封閉例項 - Java - No enclosing instance of type Foo is accessible
- C 中可變數量的引數? - Variable number of arguments in C ?
- 如何從 SHOW PROCESSLIST 檢視完整查詢 - How to see full query from SHOW PROCESSLIST
- 如何在 Mac 上的 IntelliJ IDEA 中增加 IDE 記憶體限制? - How to increase IDE memory limit in IntelliJ IDEA on Mac?
- 如何從git儲存庫中刪除原點 - How to remove origin from git repository
- 使用“==”與“strcmp()”的字串比較 - String comparison using '==' vs. 'strcmp()'
- 如何在 GitHub 上搜索提交訊息? - How can I search for a commit message on GitHub?
- 如何在matplotlib中的給定圖上繪製垂直線 - How to draw vertical lines on a given plot in matplotlib
- 如何獲取陣列中的最後一個鍵? - How to get last key in an array?
- 找到兩個字串之間的相似度度量 - Find the similarity metric between two strings
- 反轉 ArrayList 的最簡單方法是什麼? - What is the Simplest Way to Reverse an ArrayList?
- 從終端執行React Native App時出錯(iOS) - Error Running React Native App From Terminal (iOS)
- 如何替換一個字串的多個子字串? - How to replace multiple substrings of a string?
- 在 JavaScript 中宣告多個變數 - Declaring multiple variables in JavaScript
- C 中的回撥函式 - Callback functions in C
- 使用“for”迴圈迭代目錄中的所有檔案 - Iterate all files in a directory using a 'for' loop
- 居中/設定地圖縮放以覆蓋所有可見標記? - Center/Set Zoom of Map to cover all visible Markers?
- 管理 Docker 共享卷許可權的(最佳)方法是什麼? - What is the (best) way to manage permissions for Docker shared volumes?
- 什麼時候使用PHP常量“ PHP_EOL”? - When do I use the PHP constant “PHP_EOL”?
- 從遞迴到迭代的方法 - Way to go from recursion to iteration