Page 1 of 1

got mad, please help , no result overnight

Posted: Fri Apr 04, 2008 7:03 pm
by yufold

Code: Select all

<?
 
$txt = <<< endoftxt
<tr><td><div class="infobox-spacer"></div><ul><li><div>Level: 60</div></li><li><div>Requires level 60</div></li><li><div>Side: Both</div></li><li><div>Start: <a href=/?item=20644>Nightmare Engulfed Object</a></div></li><li><div>End: <a href="/?npc=11832">Keeper Remulos</a></div></li><li><div>Difficulty: <span class="r2">60</span><small> &nbsp;</small><span class="r3">63</span><small> &nbsp;</small><span class="r4">72</span></div></li></ul></td></tr><tr><th>Series</th></tr><tr><td><div class="infobox-spacer"></div><table class="series"><tr><th>1.</th><td><div><b>Shrouded in Nightmare</b></div></td></tr><tr><th>2.</th><td><div><a href="/?quest=8447">Waking Legends</a></div></td></tr></table></td></tr>
endoftxt;
 
echo preg_replace('/(?:<a href=[\/?]+\w+)[=][0-9]+>([a-zA-Z]+\s*)+/'  ,'url', $txt);
 
//echo eregi_replace("href=\"[/?]+(?=[a-z][=][0-9]\">)","ttttttt", $txt);
//echo preg_replace("/[a-z]+(?=\.[a-z]+)/","df1",$domain);
//echo $domain;
 
echo $txt;
?>
what i want is:
replace
href="/?term=204">Nightmare xxxx zzz
with
href="Nighermare xxxx zzzz">Nightmare xxxx zzz
i found (?=pat) not work on my php5.25 what problem? thanks a ton. :banghead: :banghead:

Re: got mad, please help , no result overnight

Posted: Sat Apr 05, 2008 9:44 am
by prometheuzz
Something like this perhaps?

Code: Select all

 
#!/usr/bin/php
<?php
    $text = "Both</div></li><li><div>Start: <a href=/?item=20644>Nightmare Engulfed Object</a></div></li><li><div>End";
    echo $text . "\n";
    echo preg_replace('/(?<=href=)([^>]+)>([^<]+)/', '"\2">\2', $text) . "\n";
?>