I have a concurrent bag filled with strings like this:  var bag = new ConcurrentBag&lt;string&gt;();   The collection contains 100 strings from which I need to find a phrase like in following example:  "Galaxy S7" - search phrase   And lets say the titles are:  Samsung galaxy S4 Samsung galaxy S5 Samsung galaxy S6 Samsung galaxy S7   The output that I would get is:  Samsung galaxy S4 Samsung galaxy S5 Samsung galaxy S6   I've tried it with the method "Contains" that string has like following:  var _items = new ConcurrentBag&lt;SearchItems&gt;(); Parallel.For(0, xdoc.GetElementsByTagName("item").Count, index =&gt; {     if (negative != null &amp;&amp; negative != "")     {         if (!xdoc.GetElementsByTagName("title").Item(index).InnerText.Contains(negative))         {             _items.Add(new SearchItems() {                      CurrentPrice = Convert.ToDouble(xdoc.GetElementsByTagName("convertedCurrentPrice").Item(index).InnerText),                      ItemID = xdoc.GetElementsByTagName("itemId").Item(index).InnerText,                      Title = xdoc.GetElementsByTagName("title").Item(index).InnerText });         }     }     else     {         _items.Add(new SearchItems() {                  CurrentPrice = Convert.ToDouble(xdoc.GetElementsByTagName("convertedCurrentPrice").Item(index).InnerText),                  ItemID = xdoc.GetElementsByTagName("itemId").Item(index).InnerText,                  Title = xdoc.GetElementsByTagName("title").Item(index).InnerText });     } });   The problem is, contains is not case sensitive and if I try to exclude   s7  and   S7  I don't get same results... I need some solution that is not case sensitive :/  Can someone help me out?
1138
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  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. For most cases, in mono-lingual, English code bases  answer will suffice. I'm suspecting because most people coming here fall in this category this is the most popular answer.  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.
111512
I am using this method to try find a match, in an example:  Regex.Match("A2-TS-OIL", "TS-OIL", RegexOptions.IgnoreCase).Success;   I got a true result. I am confused. I think this should return false since there is no special characters in the pattern. If I use ".+TS-OIL", true should be returned (. for any and + for more than 1). How should I do to get what I need?
116216
I used this      $this-&gt;termStorage-&gt;loadByProperties(['name' =&gt; 'test']);   I got two terms: Test, test. I want to get only one: test  This is working without case-sensitive:       $this-&gt;termStorage-&gt;getQuery()-&gt;condition('name', 'test', '=')-&gt;execute();       \Drupal::database()-&gt;select('taxonomy_term_field_data', 't')       -&gt;condition('t.name', 'test')       -&gt;fields('t', ['name'])       -&gt;execute()       -&gt;fetchAll();       \Drupal::database()-&gt;query("SELECT name FROM taxonomy_term_field_data WHERE name='test'")-&gt;fetchAll();
20332
i just made a test, to see how much data i can put in a string before i reach the the heapsize limit and i get an unexpected behaviour   string  csvFile = '"XXXXXXX","XXPX XXRXXXX","XXPX BP","XLXXXXR","XXXXVXXX PRXXXDXXXX","XXPX XXXXVXXX","XDRXXXDXX LXGXLX","XXXXRX XXLX","LXXXX XX","DXXX XXXZXX XXXXVXXX","DXXX XXXX XXXXVXXX","XXDXXX BP","XXDXXX XXXXXLX","PXRXXXX XVX","DXXXXXXXZXXXX","XXXX XXRXXXXRX","XXGXXXX XXRXXXXRX","DXXX DX XXXXXXX","LXXGX DX XXXXXXX","PXD","XXXXX XXXXRXXXXXLX","XXXX RXXXPXXX","XXDXRXZZX RXXXPXXX","PRXVXXXXX RXXXPXXX","XXXXXX RXXXPXXX","XXP RXXXPXXX","XXXXRX XXLXXXXX 1","XXXXRX XXLXXXXX 2","XXXXRX XXX","XXDXRXZZX XXXXL","XXDXRXZZX XXRXXXXRX","XXXXXX XXRXXXXRX","PRXVXXXXX XXRXXXXRX","XXP XXRXXXXRX","XXXXX XLXXXXX","XXDXXX PRXXXXX","DXXX XXXXXZXXXX","XXPX DXXXXXXXX","XHXXVX XXXXXRX","DXXX XXXXXXXXX XXXXXRX","DXXX XXXDXXZX XXXXXRX","XXPXRXX XXXXLX","XXPXRXX RXXXDXX XXXXDXXX","PRXXXXXXXXXXXXXXZXXXX PRXXXXXXXXXX","DXXX PRXXXXXXXXXXXXXXZXXXX PRXXXXXXXXXX"';  string  csvFile2='',csvFile3; system.debug(limits.getLimitHeapSize()); system.debug(limits.getHeapSize()); for(integer i=0;i&lt;3618;i++){ csvFile2+='\n'+csvFile; }   system.debug(1.0*limits.getHeapSize()); system.debug((1.0*limits.getHeapSize())/limits.getLimitHeapSize()*100);   with 3618 iteraction i get    Heap size 3001245.0 Which correspond to ~50% of the heap size limit in the Synchronous context   but if i go to 3619 iteractions in the for, i get the error "Apex heap size too large: 6001368".... which surprise me a lot...   I'm not getting out why this behaviour is occurring. Do you have any similar experience? There is a reason for this?  Seems more about limits on strings, in effect the string csvFile2 overcome 3M characters... but i dont know
111517
I need to find all occurrences of AAsomeArbitraryStringBB and replace it with CCsomeArbitraryStringDD.  So  AAHelloBB Text AAByeByeBB   becomes  CCHelloDD Text CCByeByeDD.   It's important to note that the replacement string contains part of the search string.
6541
in the System.Linq namespace, we can now extend our  to have the  and  extension methods.  I was told recently that if i want to check that a collection contains 1 or more items inside it, I should use the .Any() extension method instead of the .Count() &gt; 0 extension method because the .Count() extension method has to iterate through all the items.  Secondly, some collections have a property (not an extension method) that is Count or Length. Would it be better to use those, instead of .Any() or .Count() ?  yea / nae ?
42855
I want to search for what += means, but Google won't return any documents.  Also when I come across some PHP code I don't understand I can't search for the keywords as written.  How can I search for these special characters or include these special characters in a search.
26241
I have the following string array:  var sa = new string[] {"yabba","dabba","doo"};   I can convert it to "yabba, dabba, doo" it using string.Join() but what is the super-cool LINQ way of doing it?  The Join extension method seems promising but for a novice like me very confusing.
24862
I have a list that contains folders.   Using c# and object model, how can I see if the folder contains any items, or return a collection of all the items in that folder.
76408
When using a new Windows 8 search bar:    What is the syntax of the search expression? Is it possible to use wildcards like "*", "?" or any other special symbol?  For example, when searching with Google i can use:   '-' (minus) for excluding certain words; "quoted phrase" for exact phrase matching.
77724
I would like to write an SQL query that searches for a keyword in a text field, but only if it is a "whole word match" (e.g. when I search for "rid", it should not match "arid", but it should match "a rid".  I am using MySQL.  Fortunately, performance is not critical in this application, and the database size and string size are both comfortably small, but I would prefer to do it in the SQL than in the PHP driving it.
80627
I have a string variable that represents the name of a custom class. Example:   string s = "Customer";   I will need to create an arraylist of customers. So, the syntax needed is:  List&lt;Customer&gt; cust = new ..    How do I convert the string s to be able to create this arraylist on runtime?
92412
I have an array of 1000 or so entries, with examples below:  wickedweather liquidweather driveourtrucks gocompact slimprojector   I would like to be able to split these into their respective words, as:  wicked weather liquid weather drive our trucks go compact slim projector   I was hoping a regular expression my do the trick.  But, since there is no boundary to stop on, nor is there any sort of capitalization that I could possibly key on, I am thinking, that some sort of reference to a dictionary might be necessary?    I suppose it could be done by hand, but why - when it can be done with code! =)  But this has stumped me.  Any ideas?
71802
Is there a good way to have a Map&lt;String, ?&gt; get and put ignoring case?
4045
What is the most efficient way to write the old-school:  StringBuilder sb = new StringBuilder(); if (strings.Count &gt; 0) {     foreach (string s in strings)     {         sb.Append(s + ", ");     }     sb.Remove(sb.Length - 2, 2); } return sb.ToString();   ...in LINQ?
63512
Am not doing anything fancy, just trying to use  method of list.      List&lt;Id&gt; myIdList = new List&lt;Id&gt;(); myIdList.add('0060E000008PdMk');  Id oppId ='0060E000008PdMk';      System.debug(myIdList.contains(oppId)); //Returns false   To my surprise, I spent a few hours debugging and came with this problematic code. Are we not supposed to use contains for List&lt;Id&gt; ?  Changing the type from List&lt;Id&gt; to List&lt;String&gt; makes my code run, but I dont have any clue why it does?   Can anyone shed some light?  UPDATE : As per the suggestion of sfdcfox I have raised a case with SF support. Case number "19522568". I will keep you guys updated with the results.  UPDATE 2 : Salesforce reached out to me for this,   A bug W-4884673 already exist for this issue. SF R&amp;D team is working on the same. Known issue link for reference:   There isn't any ETA for this to be fixed, so the case will be closed as "bug fix submitted"  UPDATE 3 : This has now been resolved
27347
I would like to parse a string such as p1=6&amp;p2=7&amp;p3=8 into a NameValueCollection.  What is the most elegant way of doing this when you don't have access to the Page.Request object?