#42411 [Bgs]: clarification why not using PCRE.
| From: | axelm-php at nona dot net | Date: | Fri, 24 Aug 2007 12:16:01 +0000 |
| Subject: | #42411 [Bgs]: clarification why not using PCRE. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116620@lists.php.net to get a copy of this message | ||
ID: 42411
User updated by: axelm-php at nona dot net
-Summary: ".*" pattern triggers doubled output
Reported By: axelm-php at nona dot net
Status: Bogus
Bug Type: Regexps related
Operating System: Debian/GNU Linux
PHP Version: 5.2.3
New Comment:
Hm.. other regex implementations don't repeat the text. Well, i don't
have any interest in breaking a fight here..
With regards to PCRE - there are applications which don't allow the use
of the additional Perl functionality, but require plain POSIX regex. The
application i use it for is ENUM (RFC3761).
Thanks anyway for looking at this.
Previous Comments:
------------------------------------------------------------------------
[2007-08-24 12:04:34] jani@php.net
Expected behaviour. And you should really use PCRE functions instead.
------------------------------------------------------------------------
[2007-08-24 11:54:23] axelm-php at nona dot net
Description:
------------
The function ereg_replace() "duplicates" the replacement string when
the match string is ".*".
Example:
- input "BLABLA"
- match ".*"
- replace "TEST"
Output is "TESTTEST", although it would be expected to be "TEST".
Reproduce code:
---------------
<?
$source = "BLABLA";
$match = ".*";
$replace = "TEST";
print ereg_replace($match, $replace, $source);
print "\n";
?>
Expected result:
----------------
only a single "TEST" (as this is the case with sed, too), because i
expect ".*" to have maximum greediness.
Actual result:
--------------
see example code. produces "TESTTEST". This happens in all PHP versions
i have access to (older PHP4, current PHP4 and PHP5).
Using "^.*" as match, or ".+" works as expected.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42411&edit=1