|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-07-08 22:44 UTC] jim at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 17:00:02 2025 UTC |
I have this line I'm trying to fix: $body=eregi_replace("<([^:]*://[^ >\n\t]*)>", "<a href=\"\\1\">\\1</a>", $body); My problem here is the regexp is greedy, so everything between one < and the last > are being seen as a single match. I wanted to fix the code with: $body=eregi_replace("<([^:]*://[^ >\n\t]*?)>", "<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 > 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.