正则表达式获取pastebin.com的ID

I need to get the ID part of a pastebin link,

which is setup like http://pastebin.com/{id}, i have tired alot of different regex i am also using preg_match in php

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

or

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

Instead of regex, try using parse_url to extract the path

regex would be overkill for this.

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