Re: preg_replace

From: Date: Sat, 06 Oct 2001 18:11:31 +0000
Subject: Re: preg_replace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70232@lists.php.net to get a copy of this message
In article <20011005181616.2891.qmail@pb1.pair.com>, thunderman@younglab.de (W. Kiecksee) wrote: > I just want to replace a string with another, but I have problems, when the > string contains a [ or something similar. I just need a method to replace > "[cool]" with "text". When I use: > $mustbereplaced = "[cool]"; > $message = preg_replace("/$mustbereplaced/", "hello", $message); The square bracket is a regex special character. It must be escaped. <http://php.net/preg-quote> -- CC

« previous php.general (#70232) next »