【发布时间】:2012-05-27 11:39:36
【问题描述】:
我在 PHP 中使用 preg_replace 函数,并尝试用 bit.ly 缩短链接替换用户提交的 url:
$comment = preg_replace( '/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', '', $strText );
这将只显示评论并“清除”网址。问题是如何从文本中获取 URL 并在以后附加它?
【问题讨论】:
标签: php string preg-replace bit.ly