开发者

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:

Parse HTML styles in Regexp

Analyzer:

Parse HTML styles in Regexp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜