<?php $str = "abaaksjjkdhaf 29023487 - 1kfksdjf"; echo preg_replace('/[^\d-]/i', '', $str);
Standard input is empty
29023487-1
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!