@@ -4884,16 +4884,24 @@ defmodule Kernel do
4884
4884
@ doc ~S"""
4885
4885
Handles the sigil `~S` for strings.
4886
4886
4887
- It simply returns a string without escaping characters and without
4888
- interpolations.
4887
+ It returns a string without interpolations and without escape
4888
+ characters, except for the escaping of the closing sigil character
4889
+ itself.
4889
4890
4890
4891
## Examples
4891
4892
4892
4893
iex> ~S(foo)
4893
4894
"foo"
4894
-
4895
4895
iex> ~S(f#{o}o)
4896
4896
"f\#{o}o"
4897
+ iex> ~S(\o/)
4898
+ "\\o/"
4899
+
4900
+ However, if you want to re-use the sigil character itself on
4901
+ the string, you need to escape it:
4902
+
4903
+ iex> ~S((\))
4904
+ "()"
4897
4905
4898
4906
"""
4899
4907
defmacro sigil_S ( term , modifiers )
@@ -4930,8 +4938,9 @@ defmodule Kernel do
4930
4938
@ doc ~S"""
4931
4939
Handles the sigil `~C` for charlists.
4932
4940
4933
- It simply returns a charlist without escaping characters and without
4934
- interpolations.
4941
+ It returns a charlist without interpolations and without escape
4942
+ characters, except for the escaping of the closing sigil character
4943
+ itself.
4935
4944
4936
4945
## Examples
4937
4946
@@ -5011,8 +5020,10 @@ defmodule Kernel do
5011
5020
@ doc ~S"""
5012
5021
Handles the sigil `~R` for regular expressions.
5013
5022
5014
- It returns a regular expression pattern without escaping
5015
- nor interpreting interpolations.
5023
+ It returns a regular expression pattern without interpolations and
5024
+ without escape characters. Note it still supports escape of Regex
5025
+ tokens (such as escaping `+` or `?`) and it also requires you to
5026
+ escape the closing sigil character itself if it appears on the Regex.
5016
5027
5017
5028
More information on regexes can be found in the `Regex` module.
5018
5029
@@ -5175,8 +5186,9 @@ defmodule Kernel do
5175
5186
@ doc ~S"""
5176
5187
Handles the sigil `~W` for list of words.
5177
5188
5178
- It returns a list of "words" split by whitespace without escaping nor
5179
- interpreting interpolations.
5189
+ It returns a list of "words" split by whitespace without interpolations
5190
+ and without escape characters, except for the escaping of the closing
5191
+ sigil character itself.
5180
5192
5181
5193
## Modifiers
5182
5194
0 commit comments