Re: cvs: pear /Contact_Vcard_Build Contact_Vcard_Build.php
| From: | Daniel Convissor | Date: | Sun, 29 May 2005 14:02:08 +0000 |
| Subject: | Re: cvs: pear /Contact_Vcard_Build Contact_Vcard_Build.php | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-37863@lists.php.net to get a copy of this message | ||
On Sat, May 28, 2005 at 02:49:57PM -0000, Paul Jones wrote:
>
> + // escape colons not led by a backslash
> + $regex = '(?<!\\\\)(\:)';
> + $text = preg_replace("/$regex/i", "\\:", $text);
> +
> // escape semicolons not led by a backslash
> $regex = '(?<!\\\\)(\;)';
> $text = preg_replace("/$regex/i", "\\;", $text);
That's a bunch of inefficient code there... saving the regex to a
variable, extra escaping, two regexes. How about:
$text = preg_replace('/(?<!\\\\)(:|;)/i', '\\\$1', $text);
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409