in reply to Regular expression question
#!/usr/bin/perl # Using perl to remove svg tags from html # Because someone asked for an example # Not because this is advisable use strict; use warnings; my $htm = do { local $/; <DATA> }; $htm =~ s, <svg # begin svg tag [^>]* # svg tag attributes > # end svg tag .*? # inside svg tag (BRITTLE!) </svg> # close svg tag ,,gsx; # replace with nothing g=global, s=single-line, x=extended print $htm; __DATA__ <!DOCTYPE html> <html> <body> <svg width="100" height="100"> <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill= +"yellow" /> </svg> </body> </html>
|
---|