How to detect programming language from a string
I am looking for a way to test a particular string to determine if it contains code.

For instance, I would like to pass a string such as "body{font-weight: bold;}" and determine that it is CSS.

I would like to do it for:

HTML,
CSS,
JavaScript,
Ruby,
C,C++,C#

I am guessing that it would be regex of some sort, but I am pretty stumped!


How to detect programming language from a string
===

I am looking for a way to test a particular string to determine if it contains code.

For instance, I would like to pass a string such as "body{font-weight: bold;}" and determine that it is CSS.

I would like to do it for:

HTML,
CSS,
JavaScript,
Ruby,
C,C++,C#

I am guessing that it would be regex of some sort, but I am pretty stumped!

