title: How to apply css to div content based on regex
body: <p>I want to apply css to my div tags if the innerHtml of the div matches a regular expression. I am somehow unable to find the right search terms to google it. Please point it out to me if it has already been asked on SO.</p>
  
  <pre><code>//CSS:
  
  #main div[/* regex here which matches Foo. It will make the div red */] {
      color: red;   
  }
  </code></pre>
  
  <p>​</p>
  
  <pre><code>//HTML:
  &lt;div id="main"&gt;
      &lt;div&gt;This text contains Foo. It contains other stuff too&lt;/div&gt;
      &lt;div&gt;Red color will not be applied to this div because regex doesn't match&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have seen examples which match the attributes using regex. For example <a href="http://jsfiddle.net/7wpnL/" rel="nofollow">this</a>. I am just unable to find the right 'term' for the regex to match the contents of the div. I don't want to use Javascript and parse the text.</p>
  
  <p>PS : I don't have to have this thing on IE,Safari,Opera, so anything specific to Chrome/Mozilla would also be helpful.</p>
  
  <p>Thanks.</p>