php提取字符串中的有效链接
$link = 'https://example.com/iCXjXu8/复制此链接,打开Dou音搜索,直接观看视频!'; $pattern = '/^(https?:\/\/[a-zA-Z0-9.-]+\/\w+)/'; preg_match($pattern, $link, $matches); if(isset($matches[1])) { $result = $matches[1]; echo $result; } else { echo "无法提取链接地址"; }