【发布时间】:2013-01-19 20:26:42
【问题描述】:
我正在尝试preg_replace文本块中的所有链接,以便将它们替换为字符串"<< IMAGE >>"
我正在尝试匹配此文本块中的所有链接:
"Here we can see the chupacabra trying to eat http://somesite.com/img/chupacabra.jpg.
look at the the snails somesite.com/img/snails.png"
我正在使用这个正则表达式:
(https?:\/\/)?.*(jpg|png|jpeg|bmp|gif)
但我无法让它只选择确切的链接字符串。
我需要的是这个:
“在这里我们可以看到卓柏卡布拉试图吃东西 http://somesite.com/img/chupacabra.jpg。
看蜗牛 somesite.com/img/snails.png"
【问题讨论】:
-
这不是一个新的“问题”。请先搜索。