Hello,
I have a question regarding the result returns by Regex.compile/2
and Regex.compile!/2
.
The Elixir documentation for Regex.compile/2
and Regex.compile!/2
mentions that the second argument is binary() | [term()]
.
It means modifiers can be added this way:
iex)> {:ok, regex} = Regex.compile("foo", "i")
{:ok, ~r/foo/i}
iex> String.match?("FOO", regex)
true
But I saw a solution from exercism where regex modifiers can also be added this way:
iex> {:ok, regex} = Regex.compile("foo", [:caseless])
{:ok, ~r/foo/}
iex> String.match?("FOO", regex)
true
In the second code snippet, is it normal that the regex is printed without any regex modifiers? ({:ok, ~r/foo/}
instead of {:ok, ~r/foo/i}
)