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.
精彩评论