0
\\\\COMPUTER-NAME\\LogicalDisk(_Total)\\Avg. Disk Queue Length

I am trying to parse the above string.

What I want to achieve is to strip out

\\\\COMPUTERNAME\\

and replace with "".

The regex pattern I thought would work is:

^\\\\\\\\.*\\\\

However using http://regexpal.com/, this seems to match

\\\\COMPUTER-NAME\\LogicalDisk(_Total)\\

Can anyone help? Why is the regex pattern search just ignoring the first set of backslashes after the computer name?

Thanks

2 Answers2

1

.* is greedy so it's matching everything it can, until it reaches the last backslash.

You can use [^\\]* to match everything except backslashes.

Aron Griffis
  • 1,699
  • 12
  • 19
1

^\\{4}.+?\\{2}. That should do the job

j3ny4
  • 442
  • 2
  • 8