It looks like your regex search term does not do what you want it to do.
try this regex:
import re
text = r"The public disk is: \\diskA\FolderB\SubFolderC\FileD"
searchtext = r'\\(\\\w+)*\\'
my_regex = re.compile(searchtext)
result = my_regex.search(text)
print(result.group())
>>> \\diskA\FolderB\SubFolderC\
ok, so what's going on here? It may help to follow allong on an online regex editor such as https://regex101.com/
so it looks like your folders are allways structured
\\disk\folder\subfolder\sub-subfoler\...etc..\file
so the structure we want to look for is something starting with \\ and ending with \ in between are one or more disk\directory names using word characters.
The query is looks for a piece of text that starts and ends with a \ and has zero or more \dir statements between them. so \\, \\disk\, \\disk\dir\, all match.
putting the query together we get
\\ # the starting backslash (escaped because backslash is also a special character)
(\\\w+)* # one or more word characters (\w) preceded by an escaped backslash repeated zero or more times
\\ # finally another backslash, escaped
if you want to expand the valid characters in the file path, edit the \w part of the regex. eg if you want ( and ) as valid characters as well:
searchtext = r'\\(\\[\w()]+)*\\'
note that I added square brackets and added more characters.
The square brackets are basically optional characters... they mean any of these characters. Some characters do not need to be escaped, but some others do. eg . does not need to be escaped, but [ and ] does.
a semi complete list would be
searchtext = r'\\(\\[\w()\[\]\{\}:`!@#_\-]+)*\\'