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-
It's true that you can not select css selectors using regex, but you can select css rules using regex, so you can make the job done in the inverse way:
format css file in order to no have selectors and rules in the same line. your code should look like this:
p{
margin:0 0 10px;
}
.lead{
margin-bottom:20px;
font-size:21px;
font-weight:200;
line-height:30px;
}
select all rules (regex : (^(.)*;)
p{
margin:0 0 10px;
}
.lead{
margin-bottom:20px;
font-size:21px;
font-weight:200;
line-height:30px;
}
add some prefix to rules (example ####)
p{
####margin:0 0 10px;
}
.lead{
####margin-bottom:20px;
####font-size:21px;
####font-weight:200;
####line-height:30px;
}
select all lines not beginning with ####,not a return to line, and not a } (regex : ^[^#### \n }])
p{
####margin:0 0 10px;
}
.lead{
####margin-bottom:20px;
####font-size:21px;
####font-weight:200;
####line-height:30px;
}
add your css prefix
.my_class_prefix p{
####margin:0 0 10px;
}
.my_class_prefix .lead{
####margin-bottom:20px;
####font-size:21px;
####font-weight:200;
####line-height:30px;
}
delete the added prefix ####
.my_class_prefix p{
margin:0 0 10px;
}
.my_class_prefix .lead{
margin-bottom:20px;
font-size:21px;
font-weight:200;
line-height:30px;
}