I use in my code :
preg_match( '!http://[^?#]+\.(?:jpe?g|png|gif)!Ui' , $str[1], $results );
It work in most cases except:
src='http://www.domain.com/Pic/folder1/folder2/a.jpg_x.jpg' alt=
I get:
......older2/a.jpg
I need:
.....older2/a.jpg_x.jpg
开发者_运维问答any ideas?
Thanks in advance
$str = "src='http://www.domain.com/Pic/folder1/folder2/a.jpg_x.jpg' alt=";
preg_match("!http://[^?#']+\.(?:jpe?g|png|gif)!i", $str, $results );
var_dump($results);
I believe you need the end of expression character "$"
eg. preg_match( '!http://[^?#]+.(?:jpe?g|png|gif)$!Ui' , $str[1], $results );
NOTE: This is completely untested. Sorry I'm posting from my phone so I cant test.
精彩评论