javascript - Regexp for css font declaration -
this font declaration in css:
font: bold italic small-caps 1em/1.5em verdana,sans-serif; this regexp working value in px:
value.match(/(normal|italic)?\s*(normal|small-caps)?\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\s*(\d+)px(?:\/(normal|[\d\.]+))?\s+(.*)/); and helps me getting this:
var fontstyle = match[1], // font variant not used // fontvariant = match[2], fontweight = match[3], fontsize = match[4], lineheight = match[5], fontfamily = match[6]; i parse value font size or lineheight non px, but
[px|cm|mm|em|pt|pc|in] but i'm not able modify it. can help?
final result:
(normal|italic)?\s*(normal|small-caps)?\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\s*(\d+(?:px|cm|mm|em|pt|pc|in)*)(?:\/(normal|[\d\.]+))?\s+(.*)
just alter px in regex with:
(\d+(?:px|cm|mm|em|pt|pc|in|%)) note parenthesis.
update: value captured now.
javascript css regex
No comments:
Post a Comment