. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Wednesday, February 01, 2006

Regex To Get Class Names From CSS 2.0

I have just read part of the CSS 2.0 spec and to tie in with one of my side projects about creating a CSS 2.0 parser in c#, I have created a regex [based off the spec] that should find all the class names in a CSS file.

\.[-]?[_a-zA-Z][_a-zA-Z0-9-]*|[^\0-\177]*\\[0-9a-f]{1,6}(\r\n[ \n\r\t\f])?|\\[^\n\r\f0-9a-f]*

I intend to create more regex's over the next few days to parse all the other elements that appear inside the CSS spec. Then once these are done I should be able to have a stab at creating a full CSS 2.0 parser.

Technorati Tags
[feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed]

Related Wikipedia Documents
, , , , , ,

My Related Documents
, , , , ,

Related Amazon Books
Microsoft Log Parser Toolkit: A Complete Toolkit for Microsoft's Undocumented Log Analysis Tool: / XML Programming Using the Microsoft XML Parser: / Regular Expression Pocket Reference: / Regular Expression Recipes: A Problem-Solution Approach: / Regular Expression Recipes for Windows Developers: a Problem-solution Approach: / Programming C#: / CSS Pocket Reference: / Professional CSS: / Eric Meyer on CSS: /

Related Images From Flickr

Comments: [Add New]

Thanks for the regex, it is just what I need. Can't seem to get it to work though :-(

Any help?

static void Main(string[] args){
string css = @"


string patt = @"\.[-]?[_a-zA-Z][_a-zA-Z0-9-]*|[^\0-\177]*\\[0-9a-f]{1,6}(\r\n[ \n\r\t\f])?|\\[^\n\r\f0-9a-f]*";
string[] arr = Regex.Split(css, patt);

By Rasmus, at Sunday, February 05, 2006 7:16:00 PM

I'll check it out on monday morning. I suspect that it might be the way I pasted the code in to html :)

By Paul Kinlan, at Sunday, February 05, 2006 10:07:00 PM

I know this is an old post, but I just thought I would let you know that you're picking up images too. ;)

By Lance "ji" May, at Thursday, May 10, 2007 3:57:00 PM