Re: regexp for ' replacement

From: Date: Fri, 05 Apr 2002 18:26:35 +0000
Subject: Re: regexp for ' replacement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91769@lists.php.net to get a copy of this message
In article <Pine.LNX.4.21.0204051147590.14942-100000@aluminum.cs.pitt.edu>, thalis@cs.pitt.edu (Thalis A. Kalfigopoulos) wrote: > If I have as part of a text: > ...and then 'the quick brown fox jumped over the lazy dog's piano'... > > How can I substitute the single quote in "dog's" with say \' > I want to aply a substitution for only the single quote that is between two > single quotes and leave the rest of the text in between the same. Does this work for you? $str="...and then 'the quick brown fox jumped over the lazy dog's piano'..."; echo $str=preg_replace("/'(.*)'(.*)'/U","'$1\'$2'",$str); -- CC

« previous php.general (#91769) next »