I would like a regular expression to match a valid absolute Windows directory path, where directory names can contain spaces.
Example matches:
C:picturesholiday (without trailing backslash)
C:picturesholiday (or with trailing backslash)
C: picturesholiday
C: picturesholiday
C:pictures holiday
C:pictures holiday
C:pictures holiday
Example fails:
picturesholiday (no relative path allowed)
C:pictures*holiday (not a valid directory path)
I have tried ^[a-zA-Z]:(\w+)*([\])?$
but that does not match the spaces.
I have also tried ^[a-zA-Z]:(s)*(\w+)*(s)*([\])?$
but that works erratically.
Regular expressions are my last resort. I have also tried to validate the text box using a non-regex solution, like in this answer. But I have not found a method that works for spaces.
Thanks in advance!
See Question&Answers more detail:os