I'm wanting to scan through a css file and capture both comments and the css. I've came up with a regex that's almost there, however it's not quite perfect as it misses out properties with multiple declarations i.e.
ul.menu li a, # Won't capture this line
ul.nice-menu li a { text-decoration: none; cursor:pointer; }
Here's the regex that I'm working with:
(\/\*[^.]+\*\/\n+)?([\t]*[a-zA-Z0-9\.# -_:@]+[\t\s]*\{[^}]+\})
I've been testing this at rubular.com and here is what it currently matches, and what the array output is like.
Result 1
[0] /* Index */
/*
GENERAL
PAGE REGIONS
- Header bar region
- Navigation bar region
- Footer region
SECTION SPECIFIC
- Homepage
- News */
[1] html { background: #ddd; }
Result 2
[0]
[1] body { background: #FFF; font-family: "Arial", "Verdana", sans-serif; color: #545454;}
I must point out that I'm still a new when it comes to regular expressions, so if anyone can help and show where I'm going wrong, it'd be much appreciated :)