Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>but I want to use the regex in C#.NET.</p> </blockquote> <p>Why Regex? Believe me, you don't want to use regex. A wise man once said:</p> <blockquote> <p>Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems.</p> </blockquote> <p>Let me state your 2 problems right now:</p> <ul> <li>Retrieve information about TCP/IP configuration using ipconfig</li> <li>Parse the output from this tool using regex</li> </ul> <p>Actually you could retrieve this information using WMI directly and thus solve your original problem and never think about using regexes again:</p> <pre><code>using (var mc = new ManagementClass("Win32_NetworkAdapterConfiguration")) using (var instances = mc.GetInstances()) { foreach (ManagementObject instance in instances) { if (!(bool)instance["ipEnabled"]) { continue; } Console.WriteLine("{0}, {1}, {2}", instance["Caption"], instance["ServiceName"], instance["MACAddress"]); string[] ipAddresses = (string[])instance["IPAddress"]; string[] subnets = (string[])instance["IPSubnet"]; string[] gateways = (string[])instance["DefaultIPGateway"]; string domains = (string)instance["DNSDomain"]; string description = (string)instance["Description"]; bool dhcp = (bool)instance["DHCPEnabled"]; string[] dnses = (string[])instance["DNSServerSearchOrder"]; } } </code></pre> <p>In addition to that you could create strongly typed wrapper for those WMI classes using the <a href="http://msdn.microsoft.com/en-us/library/2wkebaxa.aspx" rel="noreferrer"><code>Mgmtclassgen.exe</code></a> utility making your code even safer and you will be able tpo get rid of the magic strings.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload