Regex.run

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

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

View Source

Specs

run(t(), binary(), [term()]) :: nil | [binary()] | [{integer(), integer()}]

Runs the regular expression against the given string until the first match. It returns a list with all captures or nil if no match occurred.

Options

  • :return - when set to :index, returns byte index and match length. Defaults to :binary.
  • :capture - what to capture in the result. Check the moduledoc for Regex to see the possible capture values.
  • :offset - (since v1.12.0) specifies the starting offset to match in the given string. Defaults to zero.

Examples

iex> Regex.run(~r/c(d)/, "abcd")
["cd", "d"]

iex> Regex.run(~r/e/, "abcd")
nil

iex> Regex.run(~r/c(d)/, "abcd", return: :index)
[{2, 2}, {3, 1}]