Sunday 15 April 2012

regex - Remove empty HTML tags from a file using sed -



regex - Remove empty HTML tags from a file using sed -

i have looked lot find solution not find one. know how remove tags using sed need remove html tags empty or have tabs or spaces in them , remove tags explicitly. example:

<p></p> or <p> </p>

i used next command remove html tags, works don't want remove tags.

sed -e 's/<[^>]*>//g' myfile.html

same command used here. kindly help me out.

you utilize below sed command remove empty tags.

sed 's/<[^\/][^<>]*> *<\/[^<>]*>//g' file

through perl,

perl -pe 's/<([^<>]*)>\s*<\/\1>//g' file

html regex linux bash sed

No comments:

Post a Comment