note 41631 modified in function.preg-replace by aidan

From: Date: Sun, 22 Aug 2004 13:09:45 +0000
Subject: note 41631 modified in function.preg-replace by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75106@lists.php.net to get a copy of this message
This took a few hours of my life. If you want to replace a string in a chunk of text WITHOUT replacing it in the html tags use the following: (i used this for a search engine to search a news database which includes html) <?php preg_replace("'(?!<.*?)$string(?![^<>]*?>)'si", "REPLACED", $chunk); ?> --was-- This took a few hours of my life. If you want to replace a string in a chunk of text WITHOUT replacing it in the html tags use the following: (i used this for a search engine to search a news database which includes html) preg_replace("'(?!<.*?)$string(?![^<>]*?>)'si", "REPLACED", $chunk); http://php.net/manual/en/function.preg-replace.php

« previous php.notes (#75106) next »