A chronological documentation test project, nothing serious, really!

12 Jun 2009 Replace specific HTML tags using sed and regular expression

In this post I would like to replace all <embed> HTML tags in a HTML file with a <strong> tag.

# sed -e 's/<embed[^>]*>/<strong>/g' filename.html > newfile.html

And if you would like to remove the <embed> tag altogether

# sed -e 's/<embed[^>]*>//g' filename.html > newfile.html

To remove all HTML tags in a file

# sed -e 's/<[^>]*>//g' filename.html > newfile.html

The result file newfile.html is now without any < HTML tags >.

Tags: , , ,

Posted by

04 Apr 2007 Remove blank / empty lines

function removeEmptyLines($string)
return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $string);

Tags: ,

Posted by