I am having a bit of trouble parsing the output of 'ipconfig /all' using a regex. Currently I am using RegexBuddy for testing, but I want to use the regex in C#.NET.
My output is:
Ethernet adapter Yes:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : MAC Bridge Miniport
Physical Address. . . . . . . . . : 02-1F-29-00-85-C9
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::f980:c9c3:a574:37a%24(Preferred)
Link-local IPv6 Address . . . . . : fe80::f980:c9c3:a574:37a7%24(Preferred)
Link-local IPv6 Address . . . . . : fe80::f980:c9c3:a574:37a8%24(Preferred)
IPv4 Address. . . . . . . . . . . : 10.0.0.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.0.0
IPv4 Address. . . . . . . . . . . : 172.16.0.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 172.16.0.254
DHCPv6 IAID . . . . . . . . . . . : 520228888
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-17-1C-CC-CF-00-1F-29-00-85-C9
DNS Servers . . . . . . . . . . . : 192.162.100.15
192.162.100.16
NetBIOS over Tcpip. . . . . . . . : Enabled
The regex I have written so far is:
([ -~]+):.+(?:Description\s)(?:\.|\s)+:\s([ -~]+).+(?:Physical Address)(?:\.|\s)+:\s([ -~]+).+(?:DHCP Enabled)(?:\.|\s)+:\s([ -~]+).+(?:(?:Link-local IPv6 Address)(?:\.|\s)+:\s([ -~]+).+Preferred.+)+
The problem is that I want to capture all the useful fields as groups, to get them easily in C#, and for some reason - when I got to capture the multiple 'Link-local IPv6 Address' fields, it stopped working.
I'll appreciate any help, Thanks.
Edit: Another problem is that I receive the ipconfig data from a remote machine (there is an unmanaged program there which I don't have control of) - thus I can't use WMI or something like that to get the ipconfig info in another way.