我有三种不同的模式来匹配soundcloud,spotify和mixcloud音频URL。我知道如何在preg_match_all php函数中逐个使用主题。但我希望在preg_match_all php函数中一次性使用这三种模式。怎么能做到这一点?
声波云模式
$soundcloud_pattern = "/((http:\/\/(soundcloud\.com\/.*|soundcloud\.com\/.*\/.*|soundcloud\.com\/.*\/sets\/.*|soundcloud\.com\/groups\/.*|snd\.sc\/.*))|(https:\/\/(soundcloud\.com\/.*|soundcloud\.com\/.*\/.*|soundcloud\.com\/.*\/sets\/.*|soundcloud\.com\/groups\/.*)))/i";Spotify模式
$spotify_pattern = "/((http:\/\/(open\.spotify\.com\/.*|spoti\.fi\/.*|play\.spotify\.com\/.*))|(https:\/\/(open\.spotify\.com\/.*|play\.spotify\.com\/.*)))/i";混合云模式
$mixcloud_pattern = "/http:\/\/(www\.mixcloud\.com\/.*\/.*\/)/i";发布于 2021-01-02 17:03:06
可以将组与OR一起使用。
(pattern1)|(pattern2)|(pattern3)https://stackoverflow.com/questions/33825983
复制相似问题