Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created April 22, 2021 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/28f6c3775c6e8c2cf724f722d2bacb42 to your computer and use it in GitHub Desktop.
Save rust-play/28f6c3775c6e8c2cf724f722d2bacb42 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn main() {
let regex = regex::Regex::new(r"(?P<qualifier>[+?~-])?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.au",
]
.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