using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?ms)(RPA\s1:).+?Initiator\sID:\s(?<RPA1Initiator>[^ ]*)";
string input = @"SITE_VPLEX:
RPAs:
RPA 1:
Version: 4.1.SP1.P1(h.167)
WAN IP: 000.000.000.000
RPA LAN IPv4: 000.000.000.000
RPA LAN IPv6:N/A
iSCSI interface IPs: None
Interfaces:
Type: FC
Initiator ID: 50012481006bexxx
Type: FC
Initiator ID: 50012481006bexxx
Type: FC
Initiator ID: 50012481006bexxx
Type: FC
Initiator ID: 50012481006bexxx
Hardware details:
Hardware type: Intel Corporation S2600GZ GEN5
Adapter type: 2564
Vendor: Intel Corporation
Hardware Serial ID: FC6RP133000229_00000000002_FFF
Hardware Platform: Intel Corporation S2600GZ GEN5
Amount of memory: 16269416 KB
Number of CPUs: 12
RPA 2:
Version: 4.1.SP1.P1(h.167)
WAN IP: 000.000.000.000
RPA LAN IPv4: 000.000.000.000
RPA LAN IPv6:N/A
iSCSI interface IPs: None
Interfaces:
Type: FC
Initiator ID: 50012481006bdxxx
Type: FC
Initiator ID: 50012481006bdxxx
Type: FC
Initiator ID: 50012481006bdxxx
Type: FC
Initiator ID: 50012481006bdxxx
Hardware details:
Hardware type: Intel Corporation S2600GZ GEN5
Adapter type: 2564
Vendor: Intel Corporation
Hardware Serial ID: FC6RP133000135_0000000000_FFF
Hardware Platform: Intel Corporation S2600GZ GEN5
Amount of memory: 16269416 KB
Number of CPUs: 12";
foreach (Match m in Regex.Matches(input, pattern))
{
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