开发者

php preg_match image address which is bagin as letter

I want to get all the image address which is a letter. I use this...

<?php
$str = <<<EOT
imag开发者_如何学编程e/20110331_121.jpg
../image/20110330_132.jpg
http://www.site.com/image/20110330_098.jpg
EOT;
$image = preg_match('#^[a-zA-Z](.*)\/.(jpg)$#i',$str);
print_r($image);// I want get a echo image/20110331_121.jpg
?>


Your problem was the \/ right before the .jpg without any placeholder. You could try this:

 $image = preg_match('#^[a-z]\w+/\w+[.](jpg)$#im',$str);

And you also forgot the #m modifier to apply ^ and $ against multiple lines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜