I would like to change the font-size in an HTML string that I have to be half of its size.
E.g.
<div style="font-family:'Arial';font-size:43px;color:#ffffff;">
Will be
<div style="font-family:'Arial';font-size:21.5px;color:#ffffff;">
and
<div style="font-size:12px;">
Will be
<div style="font-size:6px;">
How can I do it with NSRegularExpression
?
Please note that 12 and 6 and 43 and 21.5 are only examples. I need regex since it has to be a general solution for different font-size
Use a real HTML parser to preserve your sanity. An XML parser for this is incredibly fragile. There are a dozen different perfectly valid variants of the HTML syntax that will break NSAddict's expression.
I suggest reading the top voted answer on this question as it applies equally as well to HTML as it does to XHTML or XML.
RegEx match open tags except XHTML self-contained tags
Note that the iOS / OS X system frameworks include HTML/XML parsing capabilities. Use those.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With