The mod_rewrite suggestions assume that the URL in question is the URL of the script being executed. If that is not the case, but you are instead just parsing a URL from some other source, then [man]basename/man might be the simplest solution.
<?php
$url = 'http://www.someurl.com/directory/214';
$id = basename($url);
echo $id;