When trying to check a file path that could be windows or unix it took me quite a few tries to get the escape characters right.
The Unix directory separator must be escaped once and the windows directory separator must be escaped twice.
This will match path/to/file and path\to\file.exe
preg_match('/^[a-z0-9_.\/\\\]*$/i', $file_string);