gpt4 book ai didi

php - 从 PHP 中的随机文本中提取 YouTube URL

转载 作者:行者123 更新时间:2023-12-03 05:21:42 25 4
gpt4 key购买 nike

我试图从随机文本中提取 YouTube 链接。例如

这是一些随机文本,网址是 http://www.youtube.com/watch?v=-d3RYW0YoEk&feature=channel我想从 PHP 中的文本中提取这个 URL。好像想不通找到了另一种语言的解决方案,但不知道如何转换。
谢谢您的帮助。

最佳答案

您可以使用 preg_match_all 获取所有此类 URL:

if(preg_match_all('~(http://www\.youtube\.com/watch\?v=[%&=#\w-]*)~',$input,$m)){
// matches found in $m
}

关于php - 从 PHP 中的随机文本中提取 YouTube URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3649316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com