Re: Change color of anything in double/single quotes

From: Date: Sun, 26 Apr 2009 09:26:46 +0000
Subject: Re: Change color of anything in double/single quotes
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-291986@lists.php.net to get a copy of this message
That's what I was just about saying, in addition try to add the HTML entities to the regular expression as well: $string = preg_replace('/(?:& #34;|")(.*?)(?:& #34;|")/', '<font color="color">"\\1"</font>', $string); Also if you don't to get caught by the HTML validator you better surround the color name with double quotes ;) HTH, Nitsan On Sat, Apr 25, 2009 at 9:42 PM, Daniel Brown <danbrown@php.net> wrote: > On Sat, Apr 25, 2009 at 13:50, Marc Steinert <lists@bithub.net> wrote: > > > > $string = preg_replace('/"(.*?)"/', '<font > > color=color>"\\1"</font>', > > $string); > > Close, but I'd also recommend dropping in a 'Us' modifier so that > it is Ungreedy and spans lines. > > <?php > $regexp = '/"(.*?)"/Us'; > ?> > > -- > </Daniel P. Brown> > daniel.brown@parasane.net || danbrown@php.net > http://www.parasane.net/ || > http://www.pilotpig.net/ > 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#291986) next »