Codice PHP:
$a "ciao hai 19 anni";

$b preg_filter('/[^0-9]/','',$a);

echo 
$b//output: 19