RE: Newbie: special characters in regex?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux