WhiteBread v4.5.0 WhiteBread.RegexExtension

Link to this section Summary

Functions

Takes a regex and matches it against the string. Returns named groups with atoms as keys

Link to this section Functions

Link to this function atom_keyed_named_captures(regex, string)

Takes a regex and matches it against the string. Returns named groups with atoms as keys.

Examples

iex> atom_keyed_named_captures(~r/hello (?<world>[a-z]+)/, "hello earth")
%{world: "earth"}

iex> atom_keyed_named_captures(~r/(?<a>[a-z]+) (?<b>[a-z]+)/, "hello earth")
%{a: "hello", b: "earth"}

iex> atom_keyed_named_captures(~r/.+/, "hello earth")
%{}