| But I feel you are missing the point. The OP was baulking at using
| well-known, throughly tested, widely-used, published regular
| expression patterns because he didn't fully understand what all those
| strange characters in an odd format were doing.
|
| I can feel his pain. It is complex subject and takes a bit of getting
| used to - and some never quite grasp it all. (There is a reason why I
| quickly abandoned sed (vi) and grep and jumped to Emacs and "keystroke
| macros". <g>)
|
I guess that's two points. One is whether to jump
into things one doesn't understand on the say-so of
others who *seem* to know what they're talking about,
without any expert advice on possible "thin ice".
The other is whether RegExp is worth the trouble. I
once decided to get into RegExp and ended up giving
up. I just couldn't seem to get the hang of writing the
code myself. I could only use pre-designed samples.
That seemed rather reckless. Even if I trust the source,
I don't know if they've covered all possible exceptions
to the rule in their RegExp. And if I don't actually understand
the code myself then I can't check. I suppose I could just
use pre-written samples when allelse fails, but if I really
needed RegExp I'd want to just sit down and figure it
all out. So far I haven't had that need. Maybe I'm
overlooking something, but I don't see any problem
with the following for the path after the drive notation:
For i = 1 to Len(TestPathAfterDrive)
Select Case Asc(Mid(TestPathAfterDrive, i, 1))
'-- " * / : < > ? |
Case 34, 42, 47, 58, 60, 62, 63, 124
PathInvalid = True
Exit For
Case Else
'--
End Select
Next
Meanwhile, no one has actually posted code for a
RegExp solution, and even if they do, what supports
it? I only know of the scripting objects in vbscript.dll
and jscript.dll. Or one can install Perl, I suppose.
When I enter the words: windows valid path
at
regexlib.com I get no returns. The samples
there are mainly for simple checks of dates, phone numbers,
etc. Though I did find an interesting check for valid
Windows file names. I didn't know that some words are
off limits: PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT
I tried creating nul.txt and sure enough, it was rejected!
When I tried to do it with VBScript it failed with no
error. (As opposed to creating a .htaccess file. Windows
Explorer won't allow creation of a file starting with ".", but
it can be done programmatically and the resulting file is
valid.)