regex inverse

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pedroz
Forum Commoner
Posts: 99
Joined: Thu Nov 03, 2005 6:21 am

regex inverse

Post by pedroz »

Code: Select all

$a = 'asdasdasd as asdasdas <img src="http://www.domain1.com/1.gif"> sdfsdf <img src="http://www.domain2.com/1.gif">  <img src="http://www.domain3.com/1.gif">';

$pattern = '(<img[^>]+domain1.com[^>]+>)';
$a = preg_replace($pattern, '', $a);

How can I keep only img tags from domain1.com?

Any idea for an inverse like
$pattern = '!(<img[^>]+domain1.com[^>]+>)';
Post Reply