php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10218 preg_replace() with mod e, refs $10 - $19 don't work
Submitted: 2001-04-06 20:39 UTC Modified: 2001-04-16 05:12 UTC
From: karen at crazygrrl dot com Assigned:
Status: Closed Package: *Regular Expressions
PHP Version: 4.0.4pl1 OS: FreeBSD 4.2
Private report: No CVE-ID: None
 [2001-04-06 20:39 UTC] karen at crazygrrl dot com
When using preg_replace() with the modifier "e", references 
of the form \\3 or $3 don't work correctly for the numbers 
10-19, while they do for 0-9 & 20-29. A reference to $15 is 
interpreted as a reference to $1 concatenated with the 
number 5. 

Example:

$numbers = "(one) (two) (3) (4) (5) (6) (7) (8) (9) (10) 
(11) (12) (13) (14) (15#5) (16) (17) (18) (19) (20) (21) 
(22) (23)";

$pat_without_mod = "/$numbers/";

$pat_with_e_mod = "/$numbers/e";

$text = "one two 3 4 5 6 7 8 9 10 11 12 13 14 15#5 16 17 18 
19 20 21 22 23";

echo preg_replace($pat_without_mod, "'\\1 \\15 \\21'", 
$text);
// 'one 15#5 21'

echo preg_replace($pat_with_e_mod, "'\\1 \\15 \\21'", 
$text);
// one one5 21

echo preg_replace($pat_without_mod, "'$1 $15 $21'", $text);
// 'one 15#5 21'

echo preg_replace($pat_with_e_mod, "'$1 $15 $21'", $text);
// one one5 21


Configure line (via phpinfo() - I'm not the admin):
'./configure' '--with-apache=../apache_1.3.17' 
'--with-mysql=/usr/local' '--with-jpeg-dir=../jpeg-6b' 
'--with-png' '--with-gd=/usr/local' '--with-ndbm' 
'--without-ttf' '--enable-safe-mode' '--enable-dbase' 
'--enable-filepro' '--enable-ftp' '--disable-debug'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-16 05:12 UTC] jmoore@php.net
Fixed in CVS. Andrei forgot to close it.

- James
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 03:01:28 2024 UTC