Regex.run
You're seeing just the function
run
, go back to Regex module for more information.
Specs
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 forRegex
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}]