|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1683 Failing to parse/compile a *? pattern.
Submitted: 1999-07-08 22:24 UTC Modified: 1999-07-08 22:44 UTC
From: roy at idle dot com Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.11 OS: Linux redhat 5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: roy at idle dot com
New email:
PHP Version: OS:


 [1999-07-08 22:24 UTC] roy at idle dot com
I have this line I'm trying to fix:

$body=eregi_replace("&lt;([^:]*://[^ >\n\t]*)&gt;", "<a href=\"\\1\">\\1</a>", $body);

My problem here is the regexp is greedy, so everything between one &lt; and the last &gt; are being seen as a single match. I wanted to fix the code with:

$body=eregi_replace("&lt;([^:]*://[^ >\n\t]*?)&gt;", "<a href=\"\\1\">\\1</a>", $body);

This adds a question mark after the second * wildcard. In theory this might make the * match be non-greedy, so it'd match off the first &gt; and not the last. But I get an error message:

Warning: REG_BADRPT in /home/roy/public_html/phorum/post.php3 on line 183

is this really an illegal regexp? From reading the regexp docs it seems adding a ? after any * should be valid. I also tried putting the ? outside the (), which compiles, but it still matche greedily.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1999-07-08 22:44 UTC] jim at cvs dot php dot net
The ereg_* functions don't support the non-greedy extensions.
Take a look at the preg_* functions (
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 08:01:29 2023 UTC