Thanks again
davidrw, this is what I changed it to...
my $s = do {local $/=undef; <DATA>};
while( $s =~ s#<span style="([^"]+)">(?!.*?<span)(.*?)</span>#span2tag
+($1,$2)#sgei ){};
sub span2tag {
my ($attr, $s) = @_;
if ($attr =~ /bold/) { $s = "<b>$s</b>"; }
if ($attr =~ /italic/) { $s = "<i>$s</i>"; }
if ($attr =~ /underline/) { $s = "<u>$s</u>"; }
return $s;
}
__DATA__
this <span style="font-style: italic; font-weight: bold;">is</span> so
+me
this <span style="font-weight: bold;">is</span> some
<span style="font-weight: bold; text-decoration: underline;">test
<span style="font-style: italic;">text</span>
<span style="text-decoration: underline;">for</span> bolding</span>,
+ underlining and italicizing
That will take care of nested formats.
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.