正则懒惰匹配

syscgc 2009-07-13 12:48:20
<http://localhost/index.html http://localhost/index.php>
有什么办法能匹配到后面的http://localhsot/index.php?
我用的正则'/(http:\/\/localhost\/).*(.php)/';匹配
只能匹配出http://localhost/index.html http://localhost/index.php。。超尴尬.
...全文
30 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
syscgc 2009-07-13
  • 打赏
  • 举报
回复
算了。直接匹配到确实有点困难。拐个弯自个搞定了
syscgc 2009-07-13
  • 打赏
  • 举报
回复
Array ( [0] => Array ( [0] => http://localhost/index.html http://localhost/index.php> ) [1] => Array ( [0] => http://localhost/ ) [2] => Array ( [0] => index.html http://localhost/index.php> ) [3] => Array ( [0] => ) )
楼上仁兄。你那匹配的结果是..http://localhost/index.html http://localhost/index.php>.
「已注销」 2009-07-13
  • 打赏
  • 举报
回复
/(http:\/\/localhost\/)(.*)?(.php)?/

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧