You can use this:
^\\\\.*?\\
^
is a beginning of line anchor and will match only at the beginning.
.*?
is a modified version of .*
so that it will match up to the match of the pattern following it; usually called to be matching 'as little as possible', in opposition to its 'greedy' counterpart.
Alternatively, you can use a negated class:
^\\\\[^\\]+\\
[^\\]+
matches any character except backslashes.
And if you want to get server
without the backslashes, you should be able to use a capture group (by using parentheses) and extract the matched group (through $1
or \1
):
^\\\\(.*?)\\
or
^\\\\([^\\]+)\\
Or if UNC finds any first match by default, then you can simply use [^\\]+
.