What is the REGEX of a CSS selector
- by user421563
I'd like to parce a CSS file and add before every CSS selector another selector.
From:
p{margin:0 0 10px;}
.lead{margin-bottom:20px;font-size:21px;font-weight:200;line-height:30px;}
I'd like:
.mySelector p{margin:0 0 10px;}
.mySelector .lead{margin-bottom:20px;font-size:21px;font-weight:200;line-height:30px;}
But my CSS file is really complex (in fact it is the bootstrap css file) so the regex should match all CSS selectors.
For now I have this regex:
([^\r\n,{};]+)(,|{)
and you can see the result here http://regexr.com?328ps
but as you can see there are a lot of matches that shouldn't match
for example:
text-shadow:0 -1px 0 rgba(0,
matchs positive but it shouldn't
Does someone have a solution ?
THX