A regular expression to check whether a path is valid or not would be quite a substantial piece of work. For example...
C:\BON - a valid path
C:\CON - not valid
(Aside: "CON" is a special device representing the console itself, so files and directories are not allowed to be called "CON". There are other devices with similar effect. Unixey operating systems have a similar feature, however absolute paths were always used, so while you cannot name a file "/dev/stdin" in Unix, you can create "stdin" files in other directories.)
Do what everyone else has said - just go ahead and try to create the directory, then check that it exists (i.e. that creation worked).
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
|