October 6th, 2003, 01:14 PM
Hi, I have a little problem and I can't find the solution so I came here
I need to adjust link that people insert through the form. I made something like this:
$text=eregi_replace("(<a href=[\'\"][^\"\']+[\"\'])(>)([^<]+)(</a>)","\\1 target='blank' \\2 <ins>\\3</ins>\\4",$text);
It works fine - the only problem is that it only changes the last inserted link. Link before this last one remain unchanged... Anyone can help?
Thnaks in advance...
October 7th, 2003, 04:38 PM
My suggestion is to use preg_replace instead of eregi_replace. I'm not sure on the syntax of what you are doing, but from what research I've done it seems like preg_replace will be faster, and the reason I offer it as a solution is because no where could I find mention of how to parse large pieces of text with eregi_replace and have it change all instances, where in preg_replace it allows you to set a limit of how many matches you want replace (all is the default).
Neither eregi or ereg offer the limit parameter, so I'm not sure, but where I've seen it used is spam proofing email addresses, and every instance seems like it only has on address going in.
Here's the manual entry:
Zend's PHP mirror: preg_replace
Hope this is atleast a little helpful.
The owl of Minerva spreads its wings only with the falling of dusk. -Hegel
October 8th, 2003, 03:51 PM
Thank you very much for your answer. It works perfect now... THANX!