/* GroupBegin General2 */
<!-- aaa -->table html{ 这个注释也有可能是这种形式的/* asdfadf */ background-image:None;<!-- alsdkjfalsjf -->
word-spacing:normal; <!--asdfjaksdlj-->
padding-top:50px; /*asdfasdfad*/
padding-left:50px;
}
/* GroupEnd */
/* GroupBegin test113 */
/*asdfasdfad*/ 这个注释也有可能是这种形式的<!-- asdfadf -->也有可能没有注释
b p{
margin-top:50px;
margin-left:50px;
margin-right:50px;
margin-bottom:50px;
}
/* GroupEnd */
我想取到
table html
b p
也就是stylename 保留中间的空格
<!-- aaa -->table html{ 这个注释也有可能是这种形式的/* asdfadf */ background-image:None;<!-- alsdkjfalsjf -->
word-spacing:normal; <!--asdfjaksdlj-->
padding-top:50px; /*asdfasdfad*/
padding-left:50px;
}
/* GroupEnd */
/* GroupBegin test113 */
/*asdfasdfad*/ 这个注释也有可能是这种形式的<!-- asdfadf -->也有可能没有注释
b p{
margin-top:50px;
margin-left:50px;
margin-right:50px;
margin-bottom:50px;
}
/* GroupEnd */
我想取到
table html
b p
也就是stylename 保留中间的空格
text.replace(/([^/>{}]+){/gi, function(m, $1){ ret.push($1); });
alert(ret);
function getStyle(css) {
if (!isEmptyOrNull(css)) return;
var ArrayListStyle = new Array();
if (isEmptyOrNull(css)) {
css = css.replace(/\s*(\S+)\s*{([^}]*)}/g, function(m, $1) {
//css = css.replace(/^([\w \#\.\-,]+)\s*{([^}]*)}/gm, function(m, $1) {
ArrayListStyle.push($1);
return '';
});
}
else {
return;
}
alert(ArrayListStyle);
return ArrayListStyle;
}我应该怎么修改
/* GroupBegin General2*/<!--alsdkjfalsjf-->#style1 tab{background-image:None;<!-- alsdkjfalsjf -->word-spacing:normal; <!--asdfjaksdlj-->padding-top:50px; /*asdfasdfad*/padding-left:50px; } /*GroupEnd *//* GroupBegin test113 *//*asdfasdfasdfasdf*/tab tab tab table .test { margin-top:50px; margin-left:50px; margin-right:50px;margin-bottom:50px; }/*GroupEnd*/GroupBegion后面的字符要提出来。标红的部分有可能有空格。也有可能没有空格
text.replace(/\/\*\s*GroupBegin\s*([^*]+)\s*\*\//g, function(m, $1){
ret.push($1);
return m;
});
alert(ret);