Can any one provide me regex for finding all src tag. I am stuck for last two hours sometimes scripting works some times img but i want regular expression for all.
Thanks in Advance.
Can any one provide me regex for finding all src tag. I am stuck for last two hours sometimes scripting works some times img but i want regular expression for all.
Thanks in Advance.
Try this:
$pattern = '~<[^>]*?src="([^"]+)"[^>]*>~i';
This should match any tag having src
attribute.
Hope this helps.
You can use,
$html = file_get_contents("http://www.example.com");
preg_match_all ( '@src="([^"]+)"@' , $html , $match );
var_dump($match);
EDIT
To be more specific, and get all values for src and SRC in single quote or double quote
preg_match_all ( '@src=([\'"])(.*)([\'"])@' , $html , $match );
preg_match_all ( '@SRC=([\'"])(.*)([\'"])@' , $html , $match2 );
var_dump($match);
var_dump($match2);