PHP从字符串中提取
我是php新手,需要从下面的字符串中提取“url” href=\“\”>我胖吗?我只是水平挑战” Url长度因Url的不同而异 任何帮助 谢谢 您可以使用这个。请参阅演示 像这样试试PHP从字符串中提取,php,regex,Php,Regex,我是php新手,需要从下面的字符串中提取“url” href=\“\”>我胖吗?我只是水平挑战” Url长度因Url的不同而异 任何帮助 谢谢 您可以使用这个。请参阅演示 像这样试试 $string ="href=\"https://www.youtube.com/watch?v=gYDSNteP_60\">Fat, me? I'm just horizontally challenged"; $regex = '/https?\:\/\/[^\" ]+/i'; preg_match_al
$string ="href=\"https://www.youtube.com/watch?v=gYDSNteP_60\">Fat, me? I'm just horizontally challenged";
$regex = '/https?\:\/\/[^\" ]+/i';
preg_match_all($regex, $string, $matches);
print_r($matches[0]);
这将返回URL作为其唯一匹配项:
/(?<=href=").+?(?=")/i
/(?将regexp与
抱歉编辑了我的文本
/(?<=href=").+?(?=")/i
href=\\(.*)>