View Source Moar.Regex (Moar v1.60.0)

Regex-related functions.

Summary

Functions

Returns a single named capture. Can take the first two args in any order.

Like Regex.named_captures/3 but can take the first two args in any order.

Functions

Link to this function

named_capture(a, b, name)

View Source
@spec named_capture(binary() | Regex.t(), binary() | Regex.t(), binary()) :: term()

Returns a single named capture. Can take the first two args in any order.

iex> Moar.Regex.named_capture(~r/a(?<foo>b)c(?<bar>d)/, "abcd", "foo")
"b"

iex> Moar.Regex.named_capture("abcd", ~r/a(?<foo>b)c(?<bar>d)/, "foo")
"b"
Link to this function

named_captures(a, b, options \\ [])

View Source
@spec named_captures(binary() | Regex.t(), binary() | Regex.t(), [term()]) ::
  map() | nil

Like Regex.named_captures/3 but can take the first two args in any order.

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

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