<p><a href="http://arxiv.org/abs/1106.4064" rel="nofollow noreferrer">http://arxiv.org/abs/1106.4064</a> might interest you.</p>
<blockquote>
<p><strong>Algorithmic Programming Language Identification</strong></p>
<p>David Klein, Kyle Murray, Simon Weber</p>
<p>(Submitted on 21 Jun 2011 (v1), last revised 9 Nov 2011 (this version, v2))</p>
<p>Motivated by the amount of code that goes unidentified on the web, we introduce a practical method for algorithmically identifying the programming language of source code. Our work is based on supervised learning and intelligent statistical features. We also explored, but abandoned, a grammatical approach. In testing, our implementation greatly outperforms that of an existing tool that relies on a Bayesian classifier. Code is written in Python and available under an MIT license.</p>
</blockquote>
Javascript regex to detect CSS code inside a string?
<blockquote>
  <p><strong>Possible Duplicates:</strong><br>
  <a href="https://stackoverflow.com/questions/3326494/parsing-css-in-javascript-jquery">Parsing CSS in JavaScript / jQuery</a><br>
  <a href="https://stackoverflow.com/questions/4412469/parsing-css-string-with-regex-in-javascript">Parsing CSS string with RegEx in JavaScript</a>  </p>
</blockquote>



<p>How can I find out if a string contains CSS rules?</p>

<p>Example rules:</p>

<pre><code>selector {
  property:value;
}


selector { property:value; }

selector{property:value}

...
</code></pre>

<p>Basically I want to find out if a text block represents either PHP + HTML or CSS code.</p>

<p>One way to do this - I was thinking to trim the text, then match the first character of the text with <code>#</code>, <code>.</code> or a CSS selector such as <code>body</code>, <code>p</code> etc. DO you think it's a good idea?</p>