/* GroupBegin General */
style1 {
background-image:None; /*asdf*/
word-spacing:normal;
padding-top:50px;
padding-left:50px; /*asdjlajsflkj*/
padding-right:50px;
padding-bottom:50px;
}
/* GroupEnd */
/* GroupBegin test */
test {
margin-top:50px;
margin-left:50px;
margin-right:50px; /*asdjlajsflkj*/
margin-bottom:50px;
}
/* GroupEnd */
/* GroupBegin test1 */
new style1 {
}
/* GroupEnd */ 1.上面css保存在字符串中,现实遍利这个css 把/* GroupBegin General */ 这个里边的 General /* GroupBegin test */ 这个里边的 test 等等。记录到一个数组中。
2./*asdjlajsflkj*/ /*asdjlajsflkj*/把这种注释记录到另一个数组中。
请教
style1 {
background-image:None; /*asdf*/
word-spacing:normal;
padding-top:50px;
padding-left:50px; /*asdjlajsflkj*/
padding-right:50px;
padding-bottom:50px;
}
/* GroupEnd */
/* GroupBegin test */
test {
margin-top:50px;
margin-left:50px;
margin-right:50px; /*asdjlajsflkj*/
margin-bottom:50px;
}
/* GroupEnd */
/* GroupBegin test1 */
new style1 {
}
/* GroupEnd */ 1.上面css保存在字符串中,现实遍利这个css 把/* GroupBegin General */ 这个里边的 General /* GroupBegin test */ 这个里边的 test 等等。记录到一个数组中。
2./*asdjlajsflkj*/ /*asdjlajsflkj*/把这种注释记录到另一个数组中。
请教
window.onload=function(){
var aaa=document.body.innerHTML;
var re = /\/\*[^*]+\*\//g;
var ret = aaa.match(re);
for(var i=0;i<ret.length;i++){
alert(ret[i]);
}
}
</script>
<body>
/* GroupBegin General */
style1 {
background-image:None; /*asdf*/
word-spacing:normal;
padding-top:50px;
padding-left:50px; /*asdjlajsflkj*/
padding-right:50px;
padding-bottom:50px;
}
/* GroupEnd */
/* GroupBegin test */
test {
margin-top:50px;
margin-left:50px;
margin-right:50px; /*asdjlajsflkj*/
margin-bottom:50px;
}
/* GroupEnd */
/* GroupBegin test1 */
new style1 {
}
/* GroupEnd */
</body>
function change(css){
var ret1 = [], ret2 = [];
css = css.replace(/\/\* GroupBegin (.+) \*\//g, function(m, $1){
ret1.push($1);
return '';
});
css = css.replace(/\/\*\s+GroupEnd\s+\*\//g, '');
css.replace(/\/\*(.+)\*\//g, function(m, $1){
ret2.push($1);
return '';
});
alert(ret1);
alert(ret2);
}
</script>
<textarea onchange="change(this.value)"></textarea>