2011-07-29 84 views

回答

2
preg_match("~http://pastebin.com/([0-9a-zA-Z]+)~", $url, $match); 
print_r($match); 

$url = "http://pastebin.com/a65d46"; 
$parsed = parse_url($url); 
echo trim($parsed['path'])." is ID you needed"; 
1

對於這個正則表達式會是矯枉過正。

$url = "http://pastebin.com/Ugj1eqCN" 
$pos = strpos($url,"pastebin.com/"); 
echo substr($url,$pos+13);