Regex.named_captures

You're seeing just the function named_captures, go back to Regex module for more information.
Link to this function

named_captures(regex, string, options \\ [])

View Source

Specs

named_captures(t(), String.t(), [term()]) :: map() | nil

Returns the given captures as a map or nil if no captures are found.

Options

  • :return - when set to :index, returns byte index and match length. Defaults to :binary.

Examples

iex> Regex.named_captures(~r/c(?<foo>d)/, "abcd")
%{"foo" => "d"}

iex> Regex.named_captures(~r/a(?<foo>b)c(?<bar>d)/, "abcd")
%{"bar" => "d", "foo" => "b"}

iex> Regex.named_captures(~r/a(?<foo>b)c(?<bar>d)/, "efgh")
nil