I currently have a large batch of HTML text, and I have several CSS properties that resemble the following:
font:16px/normal Consolas;
font:16px/normal Arial;
font:12px/normal Courier;
which is also associated with several other CSS properties and other related HTML values and tags.
I am trying to write a regular expression that only captures these “font styles”, so if I had the following two paragraphs:
<p style='font:16px/normal Arial; font-weight: x; color: y;'>Stack</p>
<span style='color: z; font:16px/normal Courier;'>Overflow</span>
<br />
<div style='font-family: Segoe UI; font-size: xx-large;'>Really large</div>
it will match properties starting with font:and ending with a semicolon ;.
I played using RegexHero , and the closest I got:
\b(?:font[\s*\\]*:[\s*\\]*?(\b.*\b);)
which gave the following results:
font:bold;
font:12pt/normal Arial;
font:16px/normal Consolas;
font:12pt/normal Arial;
property: value;
property: value value value;
HTML, , , , , .
, .