using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?P<Timestamp>\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s+\d+\s+\d+:\d+:\d+)\b\s+(?P<FW_ip_addr>\d+\.\d+\.\d+\.\d+)\s+(?P<Event_id>%\w+-\d+-\d+):\s+(?P<Event_message>Teardown ICMP connection for faddr)\s+(?P<foreign_ip_addr>.*)\s+gaddr\s+(?P<global_ip_addr>.*)\s+laddr\s+(?P<local_ip_addr>.*)";
string input = @"Jul 25 23:56:11 210.56.128.109 %PIX-6-302021: Teardown ICMP connection for faddr 192.168.20.161/1 gaddr GAIA_172.20.8.11/0 laddr GAIA_172.20.8.11/0
Jul 25 23:56:33 210.56.128.109 %PIX-6-302021: Teardown ICMP connection for faddr Thetis2/41817 gaddr 210.56.128.109/0 laddr 210.56.128.109/0
";
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