// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r#"(?mi)^(?!\s*$)\s*(?!\s)([^#\n\[=]+?)\s*?(?>#.*?$|(?>=\s*$|=\s*?(?:#?|(".*?"|[^\s].*?)\s*?)(?:\s*#.*?$)*?$)?$)"#).unwrap();
let string = "[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
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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 Rust, please visit: https://docs.rs/regex/latest/regex/