ID: 22732 User updated by: ofjord at simnet dot is Reported By: ofjord at simnet dot is Status: Bogus Bug Type: *General Issues Operating System: windows nt PHP Version: 4.3.0 New Comment:
Thank you for your advice. Now my regex code looks like this and works perfectly: $text = eregi_replace("href=(\")?([_/a-zA-Z0-9]*[.]s?html?)(\"?)", "href=\\1template1.php?file=\\2\\3", $text); Previous Comments: ------------------------------------------------------------------------ [2003-03-15 20:33:42] [EMAIL PROTECTED] Actually, it *is* expected behavior. Your pattern is too greedy and is actually matching: ferdatjon_fyrirt_gisting.htm">Gisting</a><BR><BR> <B>•</B> <a href="ferdatjon_fyrirt_handverkshus.htm as your (.*[.]htm) pattern (see how that does match?) For a solution (making your pattern less greedy), send an email to [EMAIL PROTECTED] which is the proper forum for this type of question. Alternatively you could do some online or book research into building regex patterns. ------------------------------------------------------------------------ [2003-03-15 18:29:47] ofjord at simnet dot is I want to parse a HTML document to replace all links to .htm documents so that the .htm document becomes a parameter in a php script. Here is the code to replace the links: $text = eregi_replace("href=(\")?(.*[.]htm)(\"?)", "href=\\1template1.php?file=\\2\\3", $text); This works fine, but only once in each document. This text: <B>•</B> <a href="ferdatjon_fyrirt_gisting.htm">Gisting</a><BR><BR> <B>•</B> <a href="ferdatjon_fyrirt_handverkshus.htm">Handverkshús</a><BR><BR> returns: <B>•</B> <a href="template1.php?file=ferdatjon_fyrirt_gisting.htm">Gisting</a><BR><BR> <B>•</B> <a href="ferdatjon_fyrirt_handverkshus.htm">Handverkshús</a><BR><BR> Is this a bug? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22732&edit=1