title: Regular expression to match a valid absolute Windows directory containing spaces
body: <p>I would like a regular expression to match a valid absolute Windows directory path, where directory names can contain spaces.</p>
  
  <p><strong>Example matches:</strong></p>
  
  <pre><code>C:\pictures\holiday  (without trailing backslash)
  C:\pictures\holiday\ (or with trailing backslash)
  C:\ pictures\holiday
  C:\ pictures\holiday\
  C:\pictures \ holiday
  C:\pictures \ holiday\
  C:\pictures\ holiday \
  </code></pre>
  
  <p><strong>Example fails:</strong></p>
  
  <pre><code>\pictures\holiday (no relative path allowed)
  C:\pictures*\holiday (not a valid directory path)
  </code></pre>
  
  <p>I have tried <code>^[a-zA-Z]:(\\\w+)*([\\])?$</code> but that does not match the spaces.</p>
  
  <p>I have also tried <code>^[a-zA-Z]:(\s)*(\\\w+)*(\s)*([\\])?$</code> but that works erratically.</p>
  
  <p>Regular expressions are my last resort. I have also tried to validate the text box using a non-regex solution, like in <a href="https://stackoverflow.com/questions/1395205/better-way-to-check-if-path-is-a-file-or-a-directory">this answer</a>. But I have not found a method that works for spaces.</p>
  
  <p>Thanks in advance!</p>