I am trying to split this css file into different blocks. Everything matching /*@- to before the next one is one block. I have been trying to split this css code into separate blocks for a day now with no luck. I really would appreciate any help possible.
/*@- XYZ PAGE
--------------------------------------------------------------*/
#xyz {font-weight:normal; line-height:17px}
#xyz .fieldset-content {padding:0 20px; margin-bottom:50px}
#xyz h2 {color:#BC0000; margin:20px 0 10px 0}
/*@- ar */
#xyz ul {margin-right:25px} /* This is a normal comment */
#xyz p.top a {color:#bc0000; float:left}
#xyz .spot h2 {color:#000; float:right; margin:0}
/*@- ie6 */
#xyz .spot {clear:both}
#xyz .spot .h2seperator {float:left}
/*@- ie6 ar */
#xyz p.top a {color:#bc0000; float:left}
#xyz .spot {margin-top:80px; overflow:hidden; clear:both}
#xyz .spot h2 {color:#000; float:right; margin:0}
/*@- ie7 */
#xyz .spot .h2seperator {float:left}
/*@- ie7 ar */
#xyz .spot .h2seperator {float:right}
#xyz .spot div {float:left}
As an example this would be a single block:
/*@- ar */
#xyz ul {margin-right:25px} /* This is a normal comment */
#xyz p.top a {color:#bc0000; float:left}
#xyz .spot h2 {color:#000; float:right; margin:0}
This is another block:
/*@- XYZ PAGE
--------------------------------------------------------------*/
#xyz {font-weight:normal; line-height:17px}
#xyz .fieldset-content {padding:0 20px; margin-bottom:50px}
#xyz h2 {color:#BC0000; margin:20px 0 10px 0}
You can use positive lookahead and non-greedy quantifiers:
Explanation:
(), matching:\/\*\@-(matches/*@-).zero or more times*lazy?(?=)\/\*\@-|\zFor that to work, you must enable multiline in your regex, so the
.will match any character, including line breaks.Working example at Rubular (Edit: modified it a bit to show it’s really working; the previous example looked like a single chunk of text)