Reputation: 33
Using regex I need to extract part of a UNC path. Example:
I need to get the value after the share, so in this example i need to get:
The \server\share\ is always the same, but the number of subfolders can vary. I've tried different regex examples and working from those, but I just don't get it...
I've tried some regex with a regex tester, when I find a code where my result is in a group, I don't know how to use that specific group.
.*\\(\w\S+)\\(\w\S+)
gives a subfolder, not what I need
Upvotes: 3
Views: 1149
Reputation: 18357
Use this regex and capture your value from group1.
\bshare\\([^\\]+)
Here, \bshare
matches share as exact word followed by \
and capture one or more characters other than \
what follows after.
Upvotes: 1