I am trying to work out the preg_match command to check windows
filenames for illegal characters and I can not seem to get it right.
The disallowed characters are \/:*?"<>|
I can not figure out the correct syntax.
Here's my best guess (which does not work). I'm using % to delimit the
characters and I've added backslashes to escape most of the characters
because they are also pattern modifiers.
$matches = preg_match("%\\/:\*\?\"<>\|%", $filename);
if ($matches > 0)
echo "illegal filename - $filename";
The above does not match the colon if I submit abc: as the filename.
Any help would be much appreciated (and maybe then I can figure out how
this works).
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************