note 2333 deleted from preg_quote by mohrt
| From: | mohrt@php.net | Date: | Fri, 06 Oct 2000 02:30:12 +0000 |
| Subject: | note 2333 deleted from preg_quote by mohrt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6136@lists.php.net to get a copy of this message | ||
A good example of this is if you want to use a variable as search content that may contain
characters with special meaning to PCRE.
Here I am making every occurance of $word italicized in $textbody. The variable $word may contain
special characters and they will not affect the regular expression:
$textbody =
preg_replace("|b".preg_quote($word)."b|","<i>".$word."</i>",$textbody);