php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #1514 PCRE - request for s///e
Submitted: 1999-06-09 03:30 UTC Modified: 2007-12-16 19:58 UTC
From: rns at radar dot no Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0.9 OS: RedHat 6.0
Private report: No CVE-ID: None
 [1999-06-09 03:30 UTC] rns at radar dot no
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'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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-09 11:09 UTC] andrey at cvs dot php dot net
The bug causing segfault has been fixed in CVS.

As for the second part of your request, it is not possible to pass \\1 to
other functions since PHP itself has no concept of it.  You would have to do
preg_match() and then pass the results to a function.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 17:01:34 2024 UTC