Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created Apr 22, 2021
Embed
What would you like to do?
Code shared from the Rust Playground
fn main() {
let regex = regex::Regex::new(r"^(?P<qualifier>[+?~-])?(?P<is_a>a)(?:[:]|)?(?P<mechamism>.+)?").unwrap();
[
"a",
"a:example.com",
"~a:example.com",
"a:mailers.example.com",
"-a:mailers.example.com",
"a/24",
"-a:offsite.example.com/24]",
"mx",
"+mx:mailer.com",
]
.iter()
.copied()
.map(|string| regex.captures(string))
.for_each(|cap| println!("{:?}", cap))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment