1
的GIF ID我想一个PHP的正则表达式来从这些PHP的正则表达式得到giphy
http://i.giphy.com/VmzI60RQG0fuw.gif
https://media.giphy.com/media/VmzI60RQG0fuw/giphy.gif
http://giphy.com/gifs/VmzI60RQG0fuw
http://giphy.com/gifs/music-videos-mariah-carey-dreamlover-VmzI60RQG0fuw
我测试此提取ID(VmzI60RQG0fuw),但它不能在3概率工作
preg_match('~(media\.giphy\.com/media/([^ /]+)/giphy\.gif|i.giphy.com/([^ /]+).gif)~i', $this->url, $matches)
请注意,如果独立分析URL,'。*'可以工作。如果它们在某些情况下出现,则需要用'\ S *'替换'。*',或者甚至可以用'[^ \ s> /] *' –
好,请添加这个http:// giphy。 com/gifs/VmzI60RQG0fuw –
它是:['https?://(?| media \ .giphy \ .com/media /([^/\ n] +)/ giphy \ .gif | i \ .giphy \ .com /([^ /\n]+)\.gif|giphy\.com/gifs/(?:.*-)?([^/ \ n] +))'](https:// regex101。 COM/R/eC9gL6/3)。请注意''[']''里面的'\ n'是由于它是一个多行字符串演示而添加的,我不认为你需要它在真实的代码中。 –