Bug #1683: Failing to parse/compile a *? pattern.

From: Date: Fri, 09 Jul 1999 02:24:50 +0000
Subject: Bug #1683: Failing to parse/compile a *? pattern.
Groups: php.dev 
Request: Send a blank email to php-dev+get-8228@lists.php.net to get a copy of this message
From: roy@idle.com Operating system: Linux redhat 5 PHP version: 3.0.11 PHP Bug Type: Parser error Bug description: Failing to parse/compile a *? pattern. 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.

« previous php.dev (#8228) next »