Jump to content

replace specific links


gdfhghjdfghgfhf

Recommended Posts

I'm trying to add [DL] tags between specific links to websites like mediafire and megaupload

 

currently i use this code:

$patern ='#(<a\s[^>]*href\="([^"]*(mediafire|rapidshare|megaupload|4shared|divshare|badongo|sendspace|sharebee|sendfile|filesend|kewlshare|zshare|filestube)[^"]*)"[^>]*>).*?</a>#i';
$postmsg2 = preg_replace($patern, '[DL]$2[/DL]', $postmsg);

 

but it will only replace links embbed with <a href="">...</a>

 

i would want to also replace links that doesn't have the <a href> tags

 

so basically i'm looking for a code that would transform

to:

 

thanks a lot !

Link to comment
https://forums.phpfreaks.com/topic/203719-replace-specific-links/
Share on other sites

  • 2 weeks later...

I'm stuck at the same place because no one is helping me...

 

I could already manage to get a working code to do 50% of what i need, now i just need the other 50%

 

...and posts like this aren't helping me...

 

its not like if i'm begging for a code, i already searched and got a very good start to do what i want.

 

Wouldn't that go in a loop and keep adding [DL] and [/DL]'s?

No... just take a look at my first post i explained everything...

 

My code will add [DL] and [/DL] tags to links having the <a href> html tags. But i would also want to replace links without <a href> tags (see exemple given in first post)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.