using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?:
^
(?<host>[\w-]+\.[\w-.]*?)
\.\s*
(?<ttl>\d+)
\s*
(?<wtf>\w*)
\s*
(?<rectype>\w*)
\s*
(?<value>.*)
\s*$
)";
string input = @"agamerica-qa.commloanservices.com.
====================================
agamerica-qa.commloanservices.com. 3600 IN SOA dns001.pnc.com. hostmaster.pnc.com. 543792585 1200 180 1209600 600
agamerica-qa.commloanservices.com. 86400 IN NS dns002.pnc.com.
agamerica-qa.commloanservices.com. 86400 IN NS dns001.pnc.com.
agamerica-qa.commloanservices.com. 86400 IN NS dns000.pnc.com.
bin.agamerica-qa.commloanservices.com. 30 IN CNAME gf0.agamerica-qa.commloanservices.com.
gf0.agamerica-qa.commloanservices.com. 3600 IN A 161.150.124.249
agamerica-qa.commloanservices.com. 3600 IN SOA dns001.pnc.com. hostmaster.pnc.com. 543792585 1200 180 1209600 600
agamerica.commloanservices.com.
====================================
agamerica.commloanservices.com. 3600 IN SOA dns001.pnc.com. hostmaster.pnc.com. 543792587 1200 180 1209600 600
agamerica.commloanservices.com. 86400 IN NS dns002.pnc.com.
agamerica.commloanservices.com. 86400 IN NS dns001.pnc.com.
agamerica.commloanservices.com. 86400 IN NS dns000.pnc.com.
agamerica.commloanservices.com. 3600 IN A 161.150.133.216
bin.agamerica.commloanservices.com. 30 IN CNAME gf2.agamerica.commloanservices.com.
gf1.agamerica.commloanservices.com. 3600 IN A 161.150.116.249
gf2.agamerica.commloanservices.com. 3600 IN A 161.150.40.249
agamerica.commloanservices.com. 3600 IN SOA dns001.pnc.com. hostmaster.pnc.com. 543792587 1200 180 1209600 600";
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace;
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