Re: cvs: pear /Contact_Vcard_Build Contact_Vcard_Build.php
| From: | Philippe Jausions | Date: | Sun, 29 May 2005 15:14:57 +0000 |
| Subject: | Re: cvs: pear /Contact_Vcard_Build Contact_Vcard_Build.php | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-37867@lists.php.net to get a copy of this message | ||
Daniel Convissor wrote:
On Sat, May 28, 2005 at 02:49:57PM -0000, Paul Jones wrote:If anything, the "i" modifier can be dropped and the '\\\$1' should be '\\$1'... But I don't think that would even do what Paul is looking for due to possible escaped escaped backslashes... -PhilippeThat'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);+ // 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);