Radislav
Radislav

Reputation: 2983

How to get all size attributes from html code using regular expression

I have this code:

<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT SIZE="9" COLOR="#2C363D" LETTERSPACING="0" KERNING="0">A draft Ad for YAPAR_3743-Tv2 has been produced and is ready for your review and approval. </FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT SIZE="9" COLOR="#2C363D" LETTERSPACING="0" KERNING="0"> </FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT SIZE="9" COLOR="#2C363D" LETTERSPACING="0" KERNING="0">Thank You, </FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT SIZE="9" COLOR="#2C363D" LETTERSPACING="0" KERNING="0">LoremIpsumDolorSitAmetConsecteturAdipiscingElitNullamEgetMaurisQuam EnergisticallyUnleashProactiveIdeasWhereasHigh-PayoffTechnologies</FONT></P></TEXTFORMAT>

I need to get all size attributes with value, for example SIZE="9".

Upvotes: 0

Views: 204

Answers (1)

JotaBe
JotaBe

Reputation: 39055

Use simply this expression:

(SIZE="\d+")

If you need to also accept units, like px or %:

(SIZE="\d+(px|%)?")

Accept extra spaces in between the =

(SIZE\s*=\s*"\d+(px|%)?")

Take also into account if there are upper and lower cases (run the regex wtih case insensitive option).

Upvotes: 1

Related Questions