Community Patterns

Community Library Entry

0

Regular Expression
Created·2015-05-14 15:20
Flavor·PCRE (Legacy)

/
^([a-zA-Z]:(?=\\)|\\\\(?:[^\*:<>?\\\/|]+\\[^\*:<>?\\\/|]+|\?\\(?:[a-zA-Z]:(?=\\)|(?:UNC\\)?[^\*:<>?\\\/|]+\\[^\*:<>?\\\/|]+)))
/
Open regex in editor

Description

This extracts the "root" (e.g. drive) from a Windows path. See the unit tests for examples

Submitted by J5lx