不工作。我想我已经看得太久了,我对这个问题视而不见:
<?php
$str = $_POST['data'];
$pattern = '#(www\.|https?:\/\/){?}[a-zA-Z0-9]{2,254}\.[a-zA-Z0-9]{2,4}(\S*)#i';
if (preg_match_all($pattern, $str, $matches, PREG_PATTERN_ORDER)) {
$uri = "($matches[1])";
}
$path = parse_url($uri, PHP_URL_PATH);
$output = substr(strrchr($path, '/'), 1);
?>
示例嵌入代码 - 我需要 URL 的 a695c468 部分 - 它的长度可能会改变:
<iframe id="viddler-a695c468" src="//www.viddler.com/embed/a695c468/?f=1&offset=0&autoplay=0&secret=91361932&disablebranding=0&view_secret=91361932" width="545" height="349" frameborder="0" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>