$re = '/<img\s+[^>]*?src=["\']?([^"\'> ]+)["\']?[^>]*>/m';
$str = '<!-- works -->
<div><img class="img-responsive" src="/images/dir%20with%20spaces/file%20with%20spaces.png?ver=1.0" /></div>
<div><img class="img-responsive" src="/images/dir/file-with-accents-áépi.png?ver=1.0" /></div>
<div><img class="img-responsive" src=unquotedimage.jpg /></div>
<div><img class="img-responsive" src=unquotedimagewithdoublequote".jpg /></div>
<div><img class="img-responsive" src=unquotedimagewithsinglequote\'.jpg /></div>
<div><img class="img-responsive" src=unquotedimagewithcolon:.jpg /></div>
<!-- not working -->
<div><img class="img-responsive" src="/images/dir with spaces/file with spaces.png?ver=1.0" /></div>
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php