dounayan3643 2011-03-31 12:14 采纳率: 0%
浏览 48

php preg_match图像地址是bagin作为字母

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

<?php
$str = <<<EOT
image/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
?>
  • 写回答

1条回答 默认 最新

  • dongzi3805 2011-03-31 12:21
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法