eregi replace?
Results 1 to 3 of 3

Thread: eregi replace?

  1. #1
    Senior Member
    Join Date
    Jan 2002
    Posts
    227

    Question eregi replace?

    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...
    http://promote.opera.com/small/opera94x15.gif

    [gloworange]Sun7dots[/gloworange]

  2. #2
    Senior Member
    Join Date
    Aug 2001
    Posts
    251
    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.

    Peace,
    Dhej
    The owl of Minerva spreads its wings only with the falling of dusk. -Hegel

  3. #3
    Senior Member
    Join Date
    Jan 2002
    Posts
    227
    Thank you very much for your answer. It works perfect now... THANX!
    http://promote.opera.com/small/opera94x15.gif

    [gloworange]Sun7dots[/gloworange]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •