mitch2k
mitch2k

Reputation: 526

add selector to each line in css file

I have to add a specific id selector (#mymodule) to each CSS line. Given that there are about 20000 lines, I don't want to do this manually :).

I tried to match with regex in notepad++ using:

^((?!}|\s\s).)*$

But I get an invalid error. Trying not to re-invent the wheel, and probably I'm not the first who wants to do this, does anyone have a working regex string, or maybe some other method to achieve this?

Upvotes: 1

Views: 306

Answers (1)

Devid Farinelli
Devid Farinelli

Reputation: 7554

The easiest way is using Less/Sass that allows you to nest css selectors

You can use this online editor to generate your new CSS, just paste your CSS and wrap it with your id, compile it...and you're done!

#mymodule {
    .class1 {
        color: red;
    }
    #selector {
        color: blue;
    }
}

Upvotes: 4

Related Questions