using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?!\s*$)\s*(?!\s)([^#\n\[=]+?)\s*?(?>#.*?$|(?>=\s*$|=\s*?(?:#?|("".*?""|[^\s].*?)\s*?)(?:\s*#.*?$)*?$)?$)";
string input = @"[mysqld]
skip-grant-tables # k
bind-address=127.0.0.1
port = 3307 # test
basedir=C:\Program Files (x86)\MySQL\
datadir=C:\Program Files (x86)\MySQL\data\
default-storage-engine=INNODB
sql-mode= "" STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,test NO_ENGINE_SUBSTITUTION"" #test
max_connections=1000
tmp_table_size=1G
max_heap_table_size=1G
join_buffer_size=1M
query_cache_size =50M
query_cache_limit=50M
max_allowed_packet = 104857600
port =
= fh
thread_cache_size=8
#*** MyISAM Specific options
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=35M
key_buffer_size=25M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=256K
#*** INNODB Specific options ***
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=50M
innodb_buffer_pool_size=1000M
innodb_log_file_size=300M
innodb_thread_concurrency=8
innodb_flush_method=normal
innodb_autoinc_lock_mode=0
test=0
";
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
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