Q: Matching images links containing spaces $update = ' sometext http://www.site1.com/images/some image with spaces.jpg some other text  http://www.site2.com/some_image.jpg';

preg_match_all('#(?:<\>]+href=\")?(?:http://)?(http(s?)://([^\s]*)\.(jpg|gif|png))#',       $update, $group_imagelink);
echo $group_imagelink[1][0];
echo $group_imagelink[1][1];

My regular expression doesn't want to extract a link from text with spaces.
I need to replace spaces in the link with 20% for use after copy(), but I still want keep my text with spaces. How can I do this?
Also, is my code safe from things like http://www.myserver.com/virus.exe#fakeParam=.jpg?

A: This is what worked for me:
I replaced 
   [^\s]*

with 
   .*?

