using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"addr:([\d.]+)";
string input = @"eth0
Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:10.20.30.40 Bcast:10.20.30.254 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:66196498 errors:0 dropped:32831 overruns:0 frame:0
TX packets:61850152 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:41122659013 (41.1 GB) TX bytes:28800593238 (28.8 GB)
Interrupt:22 Memory:f6ae0000-f6b00000";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx