Re: [PHP-DEV] Bug #1514: PCRE - request for s///e From: Andrey Zmievski (zmievski <email protected>)
Date: 06/09/99

rns <email protected> wrote:
> Bug description: PCRE - request for s///e
>
> First of all, thanks for a nice fature.
>
> I've been playing with preg_replace(PATTERN, REPLACE, SUBJECT) and find it
very usefull,
> but I miss the s/PATTERN/FUNCTION/e from Perl.
>
> I would like to do something like this:
> <?php
> $tmp = "one two three";
> echo preg_replace("/(two)/", strrev("\\1"), $tmp);
> ?>
>
> BTW, this example get's a SEGFAULT
> FATAL: emalloc(): Unable to allocate 271313254 bytes
> httpd: [Wed Jun 9 10:22:17 1999] [notice] child pid 4235 exit signal
Segmentation fault (11)

I'll take a look at this.

> I've looked at the pcre.sgml, but can't find anything that can help me.
> Execution for a function works, but that doesn't help me as long I can't
use matches from
> the regexp. Is it possible to pass \\1 as a variable to a function?
>
> Rune Nordbøe Skillingstad

No, it's not possible to do that. Instead, use preg_match() to get the match
you need and pass that to a function.

-Andrey
* 2 + 2 = 5 for extremely large values of 2. *

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