Jump to content

[SOLVED] preg_match_all and preg_replace not use same regex?


maddogandnoriko

Recommended Posts

to get all youtube links I am using:

preg_match_all( "/<a[\s]+[^>]*?href[\s]?=[\s\"\']+(http:\/\/youtube.*?)[\"\']+.*?>/",$this->html,$links );

 

So I thought the same would work to replace them all with nothing, but it does not. Any hints as to why?

 

preg_replace( "/<a[\s]+[^>]*?href[\s]?=[\s\"\']+(http:\/\/rapidshare.*?)[\"\']+.*?>/",'',$this->html);

 

Thanks to all,

                    Todd

 

can you be more specific as to what's not working?  I don't know if you were just posting as an example or how you actually have it, but preg_match_all assigns the results to the specified 3rd argument like so:

 

preg_match_all($pattern, $content, $result);

print_r($result);

 

with preg_replace, the results must be assigned how things are usually assigned, like so:

 

$result = preg_replace($pattern,$replacement, $content);

 

tbh I have no idea why preg_match(_all) does not do it the same way, but..yeah...anyways, if that's not the issue, then post example content.

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.