Skip to content

Commit 05c3e98

Browse files
author
Olivier Saut
committed
Correction of small typos in Regex docs.
1 parent 212acf4 commit 05c3e98

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

lib/elixir/lib/regex.ex

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
defmodule Regex do
22
@moduledoc %S"""
3-
Regular expressions for Elixir built on top of the re module
3+
Regular expressions for Elixir built on top of the `re` module
44
in the Erlang Standard Library. More information can be found
5-
in the re documentation: http://www.erlang.org/doc/man/re.html
5+
in the [`re` documentation](http://www.erlang.org/doc/man/re.html).
66
7-
Regular expressions in Elixir can be created using Regex.compile!
7+
Regular expressions in Elixir can be created using `Regex.compile!`
88
or using the special form with `%r`:
99
1010
# A simple regular expressions that matches foo anywhere in the string
@@ -13,10 +13,10 @@ defmodule Regex do
1313
# A regular expression with case insensitive options and handling for unicode chars
1414
%r/foo/iu
1515
16-
The re module provides several options, the ones available in Elixir, followed by
16+
The `re` module provides several options, the ones available in Elixir, followed by
1717
their shortcut in parenthesis, are:
1818
19-
* `unicode` (u) - enable unicode specific patterns like \p
19+
* `unicode` (u) - enables unicode specific patterns like \p
2020
* `caseless` (i) - add case insensitivity
2121
* `dotall` (s) - causes dot to match newlines and also set newline to anycrlf.
2222
The new line setting can be overridden by setting `(*CR)` or `(*LF)` or
@@ -27,8 +27,8 @@ defmodule Regex do
2727
allow `#` to delimit comments
2828
* `firstline` (f) - forces the unanchored pattern to match before or at the first
2929
newline, though the matched text may continue over the newline
30-
* `ungreedy` (r) - invert the "greediness" of the regexp
31-
* `groups` (g) - compile with info about groups available
30+
* `ungreedy` (r) - inverts the "greediness" of the regexp
31+
* `groups` (g) - compiles with info about groups available
3232
3333
The options not available are:
3434
@@ -53,10 +53,18 @@ defmodule Regex do
5353
5454
The given options can either be a binary with the characters
5555
representing the same regex options given to the `%r` sigil,
56-
or a list of options, as expected by the Erlang `re` docs.
56+
or a list of options, as expected by the [Erlang `re` docs](http://www.erlang.org/doc/man/re.html).
5757
5858
It returns `{ :ok, regex }` in case of success,
5959
`{ :error, reason }` otherwise.
60+
61+
## Examples
62+
63+
iex> Regex.compile("foo")
64+
{:ok, %r"foo"}
65+
iex> Regex.compile("*foo")
66+
{:error, {'nothing to repeat', 0}}
67+
6068
"""
6169
@spec compile(binary, binary | [term]) :: t
6270
def compile(source, options // "")
@@ -256,7 +264,7 @@ defmodule Regex do
256264
end
257265

258266
@doc """
259-
Split the given target into the number of parts specified.
267+
Splits the given target into the number of parts specified.
260268
If no number of parts is given, it defaults to `:infinity`.
261269
262270
## Examples

0 commit comments

Comments
 (0)