javascript - Regexp for css font declaration -
This is a font declaration in CSS:
Font: bold italic small caps 1em / 1.5mm standard, non-serif;
This is a regexp working to get value in px:
value.match (/ (normal | italic)? \ S * (normal | small caps) \ s * (normal | bold | bolder | light | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900) \ s * (\ d +) pixels (?? \ /(normal[[dd.[+))?ss+(.*)/);
and helps me to get it:
var fontStyle = match [1], // font variant // fontVariant = match not used [2], FontWeight = Match [3], fontSize = Match [4], LineHight = Match [5], FontFamily = Match [6];
I would like to parse any value for font size or linehead not just px, but
[px | Cm | Mm | Em | Pt | Pc In]
But I am not able to modify it. Can anyone help?
The end result:
(normal | italic)? \ S * (normal | small-caps)? \ S * (normal | bold | boulder | light | 100 | 200 | 30 | 400 | 500 | 600 | 700 | 800 | 900 |) * (\ d + (?: | Pixels | cm | mm | to | pt | | In PC |)? *) (?: \ / (General | [\ d.] +))? \ S + (. *)
Simply enter px :
(\ d + (?: Px | cm | mm | em | pt | Update: Now the value has been captured.
/ div>