$re = '/\D(\d{5})\D/';
$str = '\\\\SERVER\\SMI Company\\SMI Technical\\SMI Drawings\\UGI\\11295- Feburary 2015 - XA-M Overhaul\\asdf.dwg
"foo.bar 123 456789"
"foo.bar 456789 123"
\\\\SERVER\\SMI Company\\SMI Administrative\\SMI Purchase Orders\\SMI-2155.GHX
"foo.bar123 "
no
"use.w.o.:this982too"
\\\\SERVER\\SMI Company\\SMI Administrative\\SMI Purchase Orders\\SMI-2355.GHX
23457f
w.o.: 12345
h4h5678
\\\\SERVER\\SMI Company\\SMI Technical\\SMI Drawings\\UGI\\11295 - Feburary 2015 - XA-M Overhaul\\asdf.dwg';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php