php匹配url的正则表达式
- 作者: 松土达人
- 来源: 51数据库
- 2022-08-23
//https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?
//PHP Example: Automatically link URL's inside text.
$text = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text);
推荐阅读
