note 15297 deleted from function.ereg-replace by jimw

From: Date: Fri, 02 Nov 2001 01:59:27 +0000
Subject: note 15297 deleted from function.ereg-replace by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20219@lists.php.net to get a copy of this message
To strip out everything before <body> and after </body> (including the body tags themselves), you can use the following: $contents = ereg_replace (".*<body[^>]*>", "", $contents); # replace everything after </body> $contents = ereg_replace ("</body>.*", "", $contents); The first line says "replace everything before <body, then everything to the first >." I use this for a tiny content management system. We can then add our own system-generated title and meta tags. BTW, I find ereg_replace to be of greater value than preg_replace because ereg_replace uses all lines of the document by default (especially handy in this example, as we may have many lines of header and footer to remove.) By default, preg_replace only finds and replaces on one line of the document at a time. Thanks to hoppysean for his help with the first example.

« previous php.notes (#20219) next »