RE: [PHP] Newbie: special characters in regex?

From: Date: Tue, 25 Sep 2007 15:43:00 +0000
Subject: RE: [PHP] Newbie: special characters in regex?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-262457@lists.php.net to get a copy of this message
> > I'm trying to modify a string so that it can be used as a Distinguished > Name in an LDAP operation. Distinguished Names must have special > characters, such as (, ), / and \ escaped with a backslash. For > instance, 'Kevin (Kev) Zembower, III" becomes 'Kevin \(Kev\) Zembower\, > III'. > > I tried to do this in this statement: > $entry['FirstName'] = preg_replace('/(\)|\(|\,|\/)/',`\\$1', > $entry['FirstName']; > Two things I can see straight off that will give you a parse error: 1. You've used a back tick instead of a single quote before \\$1 2. There's no closing parenthesis to the preg_replace function. Edward

« previous php.general (#262457) next »