Date: 05/05/00
- Next message: Wico de Leeuw: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Previous message: Rasmus Lerdorf: "Re: [PHP-DEV] is this fucntion still revavant???"
- In reply to: Wico de Leeuw: "[PHP-DEV] preg_replace and e option (bug or feature?)"
- Next in thread: Wico de Leeuw: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Reply: Wico de Leeuw: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 05 May 2000, Wico de Leeuw wrote:
> take this text:
>
> $text = "#!this 'is' a \"test\" :)!#";
>
> say i want everyting between #! and !# feed and replace to addslashes
>
> you sould say i do :
>
> $new_text = preg_replace("'#!(.*?)!#'ie", 'Addslashes("\\1")', $text);
>
> but because of the " and the ' this will fall due the eval of preg_replace
> resulting in a:
> Parse error: parse error in Unknown on line 0
>
> i suggest the founded strings in the regular can be called like this to
> overcome this problem:
> $new_text = preg_replace("'#!(.*?)!#'ie", 'Addslashes($1)', $text);
>
> Anyone has comment on this?
Yes, you should first escape ' or " in your original text with one
preg_replace() and then use another with /e modifier to feed it to your
function.
-Andrei
* The future has arrived, it's just not evenly distributed. -W. Gibson *
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Wico de Leeuw: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Previous message: Rasmus Lerdorf: "Re: [PHP-DEV] is this fucntion still revavant???"
- In reply to: Wico de Leeuw: "[PHP-DEV] preg_replace and e option (bug or feature?)"
- Next in thread: Wico de Leeuw: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Reply: Wico de Leeuw: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

