I made these regexes to match and replace html font tags, but rather than doing what they're supposed to, they end up cutting out the entire html document, save for the last line or so of text.
these are the parameters i need to meet:
-the only important attributes are COLOR, SIZE, and FACE (thus the ones i need to match and send to the correct subroutine
-the above attributes will ALWAYS be in the order of COLOR, SIZE, FACE
-each font tag could have all or any combination of above attributes
-some font tags also have BACKGROUND-COLOR and PTSIZE attributes, which could match falsely as COLOR and SIZE if they're not prefixed by whitespace
$instream =~ s/<FONT(.*?)\sCOLOR\s?=\s?('|")?(\#......)\2(.*?)\sSIZE\s
+?=\s?(\d+)(.+?)FACE\s?=\s?('|")?([^\7]+)\7[^>]*>/genStyleCSF($3,$5,$8
+)/iegs;
$instream =~ s/<FONT(.*?)\sCOLOR\s?=\s?('|")?(\#......)\2(.*?)\sSIZE\s
+?=\s?(\d+)[^>]*>\s*/genStyleCS($3,$6)/iegs;
$instream =~ s/<FONT(.*?)\sCOLOR\s?=\s?('|")?(\#......)\2(.+?)FACE\s?=
+\s?('|")?([^\5]+)\5[^>]*>\s*/genStyleCF($3,$6)/iegs;
$instream =~ s/<FONT(.*?)\sCOLOR\s?=\s?('|")?(\#......)\2[^>]*>\s*/gen
+StyleC($3)/iegs;
$instream =~ s/<FONT(.*?)\sSIZE\s?=\s?(\d+)(.+?)FACE\s?=\s?('|")?([^\4
+]+)\4[^>]*>\s*/genStyleSF($2,$4)/iegs;
$instream =~ s/<FONT(.*?)\sSIZE\s?=\s?(\d+)[^>]*>\s*/genStyleS($2)/ieg
+s;
$instream =~ s/<FONT(.+?)FACE\s?=\s?('|")?([^\2]+)\2[^>]*>\s*/genStyle
+F($3)/iegs;
Edit kudra,
2001-10-09
Changed title per ntc request
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.