Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Converting span tags.

by the_0ne (Pilgrim)
on Mar 27, 2006 at 20:05 UTC ( #539513=note: print w/ replies, xml ) Need Help??


in reply to Re: Converting span tags.
in thread Converting span tags.

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.


Comment on Re^2: Converting span tags.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://539513]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2014-07-11 17:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls