Skip to content

Commit c0bdd61

Browse files
mrcasalsjosevalim
authored andcommitted
Improve docs for sigil_r (#11051)
1 parent e7cb210 commit c0bdd61

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5554,7 +5554,7 @@ defmodule Kernel do
55545554
quote(do: List.to_charlist(unquote(unescape_list_tokens(pieces))))
55555555
end
55565556

5557-
@doc """
5557+
@doc ~S"""
55585558
Handles the sigil `~r` for regular expressions.
55595559
55605560
It returns a regular expression pattern, unescaping characters and replacing
@@ -5564,12 +5564,15 @@ defmodule Kernel do
55645564
55655565
## Examples
55665566
5567-
iex> Regex.match?(~r(foo), "foo")
5567+
iex> Regex.match?(~r/foo/, "foo")
55685568
true
55695569
55705570
iex> Regex.match?(~r/a#{:b}c/, "abc")
55715571
true
55725572
5573+
While the `~r` sigil allows parens and brackets to be used as delimiters,
5574+
it is preferred to use `"` or `/` to avoid escaping conflicts with reserved
5575+
regex characters.
55735576
"""
55745577
defmacro sigil_r(term, modifiers)
55755578

0 commit comments

Comments
 (0)