#24645 [Opn->Bgs]: ereg_replace fails to strtolower replaced string

From: Date: Mon, 14 Jul 2003 14:21:11 +0000
Subject: #24645 [Opn->Bgs]: ereg_replace fails to strtolower replaced string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43951@lists.php.net to get a copy of this message
ID: 24645 Updated by: jay@php.net Reported By: nek at capsule dot org -Status: Open +Status: Bogus Bug Type: Regexps related Operating System: Linux PHP Version: 4.3.1 New Comment: That's correct, so this is bogus. Try using ereg()/preg_match() with the optional registers used in the third argument to get the results you're looking for. J Previous Comments: ------------------------------------------------------------------------ [2003-07-14 09:19:55] nek at capsule dot org well, maybe the matching string should be considered as a normal one, so we can use some functions on it. this would render ereg_replace function even more powerfull, isn't it ? ------------------------------------------------------------------------ [2003-07-14 09:09:01] b_ulrich at t-online dot de Using strtolower("HREF=\"\\1\"") as parameter is like using "href=\"\\1\"" directly. First the strtolower is processed and then that result is used as parameter. You have to change your search/replace pattern to get what you want. The function works correct. ------------------------------------------------------------------------ [2003-07-14 08:39:01] nek at capsule dot org sorry, it's php 4.3.1 and not 4.3.2 ------------------------------------------------------------------------ [2003-07-14 08:37:18] nek at capsule dot org Description: ------------ Hi, i'm trying to replace a portion of string by its strtolowered equivalent see reproduce code and results below : it should give "href=javascript:comment()" but only "HREF" is lowered, not the matching string \1 Reproduce code: --------------- <?php $newsaff = "<A HREF=\"JAVASCRIPT:COMMENT()\">THIS IS A TEST LINK</A>"; $newsaff = ereg_replace("HREF=\"([^\"]+)\"",strtolower("HREF=\"\\1\""),$newsaff); print $newsaff; ?> Expected result: ---------------- <A href="javascript:comment()">THIS IS A TEST LINK</A> Actual result: -------------- <A href="JAVASCRIPT:COMMENT()">THIS IS A TEST LINK</A> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24645&edit=1

« previous php.bugs (#43951) next »