in reply to Remove all html tag Except 'sup'
my $tag = qr{ <(?>/?) # tag start (?!sup) # not a <sup> or </sup> tag [^>]* # everything but the tag end+ > # end of tag }xi; $str =~ s/$tag//g;
This is untested and probably a bad idea, but you asked for it ;-)
Update: fixed regex to preserve closing tag. Stupid me. It tried to match <c/sup</c>, failed, backtracked, and matched that whole substring with the [>]* rule. Non-backtracking groups around /? prevents that. In perl 5.10 you could also say /?+ instead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Remove all html tag Except 'sup'
by jai_dgl (Beadle) on Jun 20, 2008 at 10:09 UTC | |
by Anonymous Monk on Jun 20, 2008 at 10:52 UTC | |
by waldner (Beadle) on Jun 20, 2008 at 11:51 UTC | |
by moritz (Cardinal) on Jun 20, 2008 at 10:44 UTC | |
by Anonymous Monk on Jun 20, 2008 at 10:59 UTC |