Artem Makarov
Artem Makarov

Reputation: 874

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.

Upvotes: 1

Views: 311

Answers (1)

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56162

Try this:

\.?\w+\s*{\s*(?:(?:(?<name>[^{};]+)\s*:\s*(?<value>[^{};]+));?)+\s*}

Output: enter image description here

Analyzer: enter image description here

Upvotes: 1

Related Questions