Skip to content

Instantly share code, notes, and snippets.

@Bas-Man
Created April 20, 2021 14:44
Show Gist options
  • Save Bas-Man/dbdff9835e0106e3e3b6a2890443e948 to your computer and use it in GitHub Desktop.
Save Bas-Man/dbdff9835e0106e3e3b6a2890443e948 to your computer and use it in GitHub Desktop.

Revisions

  1. Bas-Man created this gist Apr 20, 2021.
    15 changes: 15 additions & 0 deletions spf_a_mechanism_regex.rs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    fn main() {
    let regex = regex::Regex::new(r"(?P<a_only>a$)|(?:a:)(?P<a_colon>[^/].+)|(?P<a_slash>a/\d{1,2})").unwrap();

    [
    "a",
    "a:example.com",
    "a:mailers.example.com",
    "a/24",
    "a:offsite.example.com/24]",
    ]
    .iter()
    .copied()
    .map(|string| regex.captures(string))
    .for_each(|cap| println!("{:?}", cap))
    }