Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Answer: how-to strip empty HTML tags like b /b

by Hofmator (Curate)
on Sep 06, 2001 at 17:20 UTC ( #110566=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > how-to strip empty HTML tags like <b> </b> - Answer contributed by Hofmator

I'd also go with tachyon's suggestion of HTML Tidy, but if you are trying to do this quick and dirty somewhere in the middle of a script, I'd use this regex $text =~ s#<\s*([^>]*)\s*>[\s\n]*<\s*/\s*\1\s*>##ig;
It should remove any empty tags which don't contain any attributes (not just bold tags), so it works on

__DATA__ <i> </ I> < B ></b> < em> < / eM >

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
shmem seeks a tate and smikes a pope
shmem .oO( Ca n'est pas un pipe )
[shmem]: ah well. goodn.(1<<3) folks

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-03-28 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (342 votes). Check out past polls.