@Richie, do you really need the second backslash just before the dot separator? shouldn't it be ...}\\]+\.[^/?....
–
Rob WellsJun 23 '09 at 12:15

2

@Rob Wells: It is necessary since PHP strings use the backslash as an escape character as well. "\\" in a PHP string is translated to "\" in the regex. That "\." is translated to "\." is a coincidence resulting from the fact that "\." has no meaning to PHP and is therefore left unchanged. Nontheless it is sloppy not to escape the backslash.
–
TomalakJun 23 '09 at 12:18

You can of course you something other than "/" to delimit the regex in preg_match(), this removes the need to escape forward slashes specifically, but adds the need to escape the new delimiter character (if you want to use it in the regex).
–
TomalakJun 23 '09 at 12:13

2

Warning ! A filename like . or .. can be dangerous in some case, and is valid with ^[^/?*:;{}\\]*\.?[^/?*:;{}\\]+$
–
rap-2-hJun 19 '12 at 10:17