Parse HTML styles in Regexp
Don't know how to create a Regexp开发者_如何转开发 request to check smth like that:
p {
margin:0
}
.c0 {
width:468.0pt;
background-color:#ffffff;
padding:72.0pt 72.0pt 72.0pt 72.0pt
}
.c1 {
direction:ltr
}
It's a part of style in HTML document.So, p - tag, in every style of this tag (c0, c1, etc) there could be different count of properties, Every property has format of PROPERTY_NAME:PROPERTY_VALUE and this properties separated with ;
How to consider all of this things in one Regexp?
Thanks a lot.
Try this:
\.?\w+\s*{\s*(?:(?:(?<name>[^{};]+)\s*:\s*(?<value>[^{};]+));?)+\s*}
Output:
Analyzer:
精彩评论