diff --git a/libs/utils/src/Path.cpp b/libs/utils/src/Path.cpp index e31fa3469d..781508e086 100644 --- a/libs/utils/src/Path.cpp +++ b/libs/utils/src/Path.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #if defined(WIN32) # include @@ -185,12 +184,12 @@ std::vector Path::split() const { size_t current; ssize_t next = -1; - // Matches a leading disk designator (C:\), forward slash (/), or back slash (\) - const static std::regex driveDesignationRegex(R"_regex(^([a-zA-Z]:\\|\\|\/))_regex"); - std::smatch match; - if (std::regex_search(m_path, match, driveDesignationRegex)) { - segments.push_back(match[0]); - next = match[0].length() - 1; + // If there is a leading disk designator such as C:, this naturally becomes the first segment. + // However if there there is leading slash or back slash, we need to explicitly preserve it. + // Note that we are guaranteed to have at least one char in the path at this point. + if (m_path[0] == '/' || m_path[0] == '\\') { + segments.push_back(m_path.substr(0, 1)); + next = 0; } do {