using System.Collections.Generic;
using System.Text.RegularExpressions;
public static void Main()
var response = @"IP Address, IP_ID, HostName, FirmwareName
172.21.7.211 : 0 : DEV-AM-200 : AM-200 [v1.3975.00025 (February 14 2019), #FFFFFFFF] @E-00107f9be7c5
172.21.7.52 : 0 : MA-CP3 : CP3 [v1.503.3568.26236 (Oct 09 2018), #00AEC621] @E-00107f526810
172.21.7.207 : 0 : DEVLIGHTING : RMC3 [v1.504.3687.32251 (Feb 05 2019), #00ED0725] @E-00107f87c377
172.21.7.208 : 0 : OFFICE-DMPS3 : DMPS3-300-C [v1.502.3081.24394 (Jun 09 2017), #00F2E861] @E-00107f89ca44
172.21.7.67 : 0 : DM-MD8x8-00107F7E5C11 : DM-MD8x8 Cntrl Eng [v4.102.352400038 (Dec 13 2017), #00EC0E71]
172.21.7.212 : 7 : TS-1542-00107F9C4DDB : TS-1542 [v1.3781.00029 (March 07 2019), #01414012] @E-00107f9c4ddb
ProcessResponse(response);
private static void ProcessResponse(string response_) {
var devices = new List<Device>();
devices = ParseTable(response_);
foreach(var device in devices) {
Console.WriteLine(device.IpAddress);
Console.WriteLine(device.IpId);
Console.WriteLine(device.HostName);
Console.WriteLine(device.Firmware);
private static List<Device> ParseTable(string table_) {
var devices = new List<Device>();
var matchCollection = Regex.Matches(table_,
@"(?:\s{4,5})(?<ipAddress>.)(?:\s{1,5})(?<ipId>.+?)(?:\s{1,4})(?<hostName>.+?)(?:\s{1,10})(?<firmware>.*)",
if (matchCollection.Count <= 0) {
foreach (var match in matchCollection.Cast<Match>().Where(match_ => match_.Success)) {
devices.Add(new Device() {
IpAddress = match.Groups["ipAddress"].Value ?? string.Empty,
IpId = match.Groups["ipId"].Value ?? string.Empty,
HostName = match.Groups["hostName"].Value ?? string.Empty,
Firmware = match.Groups["firmware"].Value ?? string.Empty,
public string IpAddress { get; set; }
public string IpId { get; set; }
public string HostName { get; set; }
public string Firmware { get; set; }