// 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"(?mx)(?:
^
(?<host>[\w-]+\.[\w-.]*?)
\.\s*
(?<ttl>\d+)
\s*
(?<wtf>\w*)
\s*
(?<rectype>\w*)
\s*
(?<value>.*)
\s*$
)").unwrap();
let string = "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";
// 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/