. 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

Friday, February 24, 2006

C# CSS Classname Regex

As promised, although a little late I have updated the Regex to get CSS classnames via C#. The problem I had was that it would find file extensions in a url specified by the "url(xyz.png)" in an attribute.

I added a little negative look behind and now it seems to work prety well:

string css = @"
.someclass
{
background: white url(someimage.png) repeat-x top left;
}
.someclass2
{
background: white url ( someimage.png) repeat-x top left;
}
";
MatchCollection arr = Regex.Matches(css, @"(?<!url\s*\(.*)(\.[-]?[_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 class1 = arr[0].Value;
string class2 = arr[1].Value;

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

Related Wikipedia Documents
, , , , , , ,

My Related Documents
, ,

Related Amazon Books
Compressed Image File Formats: JPEG, PNG, GIF, XBM, BMP (ACM Press S.): / PNG: The Definitive Guide: / Web Designer's Guide to PNG, GIF, JPEG: / CSS Pocket Reference: / Professional CSS: Cascading Style Sheets for Web Design: / Regular Expression Pocket Reference: / Regular Expression Recipes: A Problem-Solution Approach: / Regular Expression Recipes for Windows Developers: a Problem-solution Approach: /

Related Images From Flickr

Comments: [Add New]

Hi
I am looking for RE which parse class by Name and then return its content

For instance if a class is defined as

.mYclass{
background:red;
left:10px;
right:10px
}
then it returnt the content of class with in bracket. Can you please guide me?

By Adnan, at Saturday, August 18, 2007 9:18:00 AM