/* 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*/把这种注释记录到另一个数组中。
请教

解决方案 »

  1.   

    <script>
    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>
      

  2.   

    谢谢您的帮忙。我只想拿出/* GroupBegin General */  这个里边的 General 不要GroupBegin   /* GroupBegin test */   拿出test
      

  3.   

    <script type="text/javascript">
    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>
      

  4.   

    谢谢帮助 ret1 对了。ret2还有点小问题 /*asdf*/ 要取这种形式的 在麻烦一下。谢谢。
      

  5.   

    ret2.push($1);改成ret2.push(m);即可