title: How to delete one items in List C#?
body: <p>I have <code>List&lt;String&gt;</code> include nine items.</p>
  
  <p>I want to delete at item contains: <code>&amp;nbsp;</code>.</p>
  
  <p>I do this with code:</p>
  
  <pre><code>foreach (string text in listHeader[0])
  {
      if (text.Contains("&amp;nbsp"))
      {
          listHeader[0] = listHeader[0].SelectMany(line =&gt;
                                         {
                                             line.Replace("&amp;nbsp;", "");
                                             return new String[] { line };
                                         }).ToList();
      }
  }
  </code></pre>
  
  <p>But <code>listHeader[0]</code> also have nine items. How to fix my code to delete item contains <code>&amp;nbsp;</code>.</p>
  
  <p>Sample data:</p>
  
  <pre><code>listHeader[0]= {
                     text
                     sample
                     new string
                     &amp;nbsp;
                 }
  </code></pre>
  
  <p>Another case my <code>listHeader[1]</code> need filter with start with <code>&lt;!--&lt;div</code> to <code>&lt;/div&gt;--&gt;</code>.</p>
  
  <pre><code>foreach (string text in listHeader[1])
  {
      listHeader[1] = Regex.Replace(text, "&lt;!--&lt;div.*?&lt;/div&gt;--&gt;", "").ToList();
  }
  </code></pre>
  
  <p>My question is:</p>
  
  <p>How to remove item contains string start with <code>&lt;!--&lt;div</code> and end at <code>&lt;/div&gt;--&gt;</code></p>
  
  <p>Sample:</p>
  
  <pre><code>listHeader[1] = {
  go to school
  
  &lt;!--&lt;div id='fav_0118668891'class='icon displayOn' &gt;&lt;span class='favorite' onclick='javascript:addMatchFavorites("0118668891","014018",false,false);' title='undefined'&gt;&lt;/span&gt;&lt;/div&gt;--&gt;
  
  work at the company
  
  take a coffee
  }
  </code></pre>
  
  <p>My resolve:</p>
  
  <p>In this case:</p>
  
  <p>I using <code>StartWith</code> and <code>EndWith</code> to find this string and <code>Remove</code>.</p>
  
  <pre><code>listHeader[1].RemoveAll(x =&gt; x.StartsWith("&lt;!--&lt;div") &amp;&amp; x.EndsWith("&lt;/div&gt;--&gt;"));
  </code></pre>