SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Ereg problem

  1. #1
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ereg problem

    I want to replace each link text in this page:

    Code:
     <br>
     Sabena-vakbonden krijgen nog 24 uur<br>
    <br>
     Directie halveert aantal ontslagen. <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=111&g=on&s=0&r=0">111</a><br>
     Referendum als er geen akkoord is <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=111&g=on&s=0&r=0">111</a><br>
    <br>
     VUM schrapt 183 vaste banen <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=114&g=on&s=0&r=0">114</a><br>
    <br>
     Woensdag ontmoeting Peres en Arafat <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=150&g=on&s=0&r=0">150</a><br>
    <br>
     TERREUR VN verwacht exodus Afghanen <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=147&g=on&s=0&r=0">147</a><br>
     Michel met EU-delegatie in Pakistan <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=142&g=on&s=0&r=0">142</a><br>
     Waarschuwing Blair voor Taliban <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=141&g=on&s=0&r=0">141</a><br>
     <br><b>Laatste nieuws</b><br>
     Duivelspaar schuldig over hele lijn <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=139&g=on&s=0&r=0">139</a><br>
     Kindermoordenaar Stokx overleden. <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=139&g=on&s=0&r=0">139</a><br>
     Luchtvaart: Vinci wil TBI niet meer <a class="no" target="blank" href="http://www.tv1.be/tt/tt.php?p=169&g=on&s=0&r=0">169</a><br>
    with this eregi_replace:
    ($filter[1] is the text above)
    PHP Code:
    <?
    $filter
    [1] = eregi_replace("&g=on&s=0&r=0\">(.*)</a>","&g=on&s=0&r=0\">more </a>",$filter[1]);
    ?>
    This script works, but only for the first replace, the script stops executing after his first replace...

    what's wrong with it?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That would match everything between the first <a and the last </a> so it would replace all of it with teh one little &g=on&s=0&r=0\">more </a>

    Change the ereg line to

    PHP Code:
    $filter[1] = eregi_replace("&g=on&s=0&r=0\">([^<]*)</a>","&g=on&s=0&r=0\">more </a>",$filter[1]); 
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much!

    It works fine!


Bookmarks

Posting Permissions

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