using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"name\[(?<policy_name>[\w\.\-\d\s]+)\]uuid\[(?<uuid>[\w\d\.\-\s]+)\]srcintf\[(?<source_interface>[\w\.\-\s\d]+)\]dstintf\[(?<destination_interface>[\w\d\-\.\s]+)\]srcaddr\[(?<source_address>[\w\d\.\-\s]+)\]dstaddr\[(?<destination_address>[\w\d\.\-\s]+)\]action\[(?<policy_action>\w+)\]schedule\[(?<policy_schedule>[\w\d\s\.\-]+)\]service\[(?<policy_services>[\w\s\.\d\-]+)\](utm-status\[(?<utm_status>[\w\s\.\-\d]+)\])?logtraffic\[(?<log_traffic>[\d\w\s\.\-]+)\]ippool\[(?<pool_status>[\s\w\d\.\-]+)\]poolname\[(?<pool_name>[\w\s\d\.\-]+)\](profile-protocol-options\[(?<protocol_options>[\w\s\d\.\-]+)\]ssl-ssh-profile\[(?<ssl_ssh_profile>[\w\d\.\s\-]+)\]ips-sensor\[(?<ips_sensor>[\w\d\s\.\-]+)\])?nat\[(?<nat_status>[\w\d\s\.\-]+)\]";
string input = @"name[BDC-OMNIChannel-Server-OUT]uuid[260b133c-6dfc-51eb-d0a5-eff41f9c9cea]srcintf[INT-To-CoreWAN TO-FG3700-DC-IC]dstintf[SERVICE-INT-OUTSIDE]srcaddr[Omni-Channel-Testbed]dstaddr[all]action[accept]schedule[always]service[DNS HTTP HTTPS PING]utm-status[enable]logtraffic[all]ippool[enable]poolname[INTERNET-SERVICES-OUTBOUND-POOL]profile-protocol-options[default]ssl-ssh-profile[certificate-inspection]ips-sensor[high_security]nat[enable]";
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