title: Parse a CSS file with PHP
body: <p>I want to parse (in a special way) a CSS file with PHP.</p>
  <p>Example:</p>
  <p><code>cssfile.css</code>:</p>
  <pre><code>#stuff {
      background-color: red;
  }
  
  #content.postclass-subcontent {
      background-color: red;
  }
  
  #content2.postclass-subcontent2 {
      background-color: red;
  }
  </code></pre>
  <p>And I want that PHP returns me each class name that have the postclass in its name.</p>
  <p>The result look like an array having in this example:</p>
  <pre><code>arrayentry1:
  #content.postclass-subcontent
  arrayentry2:
  #content2.postclass-subcontent2
  </code></pre>
  <p>But I'm worse at regular expressions. somehow search for &quot;postclass&quot; and then grap the hole line and put into an array.</p>
  <hr />
  <p>thank you and i used it to parse a css file simliar to a confic file.</p>
  <pre><code>$(function () {
      $.get('main.css', function (data) {
          data = data.match(/(#[a-z0-9]*?\ .?postclass.*?)\s?\{/g);
          if (data) {
              $.each(data, function (index, value) {
                  value = value.substring(0, value.length - 2);
                  $(value.split(' .')[0]).wrapInner('&lt;div class=&quot;' + value.split('.')[1] + '&quot; /&gt;');
              });
          }
      });
  });
  </code></pre>
  <p>was my final code. so i can wrap easily a div around some hardcode-html without editing the layout. so i just have to edit my cssfile and add there something like</p>
  <h1>id .postclass-class { some styles }</h1>
  <p>and my code searchs for the id and wraps the inner content with an div. i needed that for quickfixes when i just have to add a div around something for a clear or a background.</p>