0

I have the following CSS File:

.garage {
    width: 100px;
    height: 200px; /*Extract*/
}
.showroom {
    color: #FFF;
    text-align: right;
    padding: 20px 30px; /*Extract*/
}
#dealer-lot {
    width: 500px; /*Extract*/
    background-color:#CCC; 
}

I'd like to find each occurrence of the keyword (/*Extract*/) and extract the child and containing parent to a new file. For example:

.garage {
    height: 200px; /*Extract*/
}

I'm not particularly sure if it would be possible to do this. I"m currently using strpos() to find the keyword and including the keyword (/*Extract*/) at every open/close brace, but it's tedious and it's prone to errors if you forget to add the keyword on each line you'd like to extract from the file. Here is an example of what I currently need to do to achieve the desired outcome:

.garage { /*Extract*/
    width: 100px;
    height: 200px; /*Extract*/
} /*Extract*/

Is there a more reliable method in which to find the closest open/close brace from the keyword?

thinkus
  • 13
  • 1
  • 5
  • See the following for some clues: http://stackoverflow.com/questions/3618381/parse-a-css-file-with-php, http://stackoverflow.com/questions/236979/parsing-css-by-regex – user1032531 Mar 03 '13 at 18:29
  • I'll review these and rework the code to see if I can make it work. Thank you. – thinkus Mar 03 '13 at 18:33

0 Answers0