Skip to content

Commit 65d1215

Browse files
demerphqjosevalim
andauthored
Apply suggestions from code review
Minor fixups and simplifications. Co-authored-by: José Valim <[email protected]>
1 parent 9bce632 commit 65d1215

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/elixir/lib/regex.ex

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,17 @@ defmodule Regex do
423423
options had not be used and the function will not raise any exceptions.
424424
425425
Embeddable modifiers/options are currently:
426-
* 'i' - :caseless
427-
* 'm' - :multiline
428-
* 's' - :dotall, :newline, :anycrlf})
429-
* 'x' - :extended
430426
431-
And unembeddable modifiers are
432-
* 'f' - :firstline
433-
* 'U' - :ungreedy
434-
* 'u' - :unicode, :ucp
427+
* 'i' - `:caseless`
428+
* 'm' - `:multiline`
429+
* 's' - `:dotall, {:newline, :anycrlf}`
430+
* 'x' - `:extended`
431+
432+
And unembeddable modifiers are:
433+
434+
* 'f' - `:firstline`
435+
* 'U' - `:ungreedy`
436+
* 'u' - `:unicode, :ucp`
435437
436438
Any other regex compilation option not listed here is considered unembeddable.
437439
@@ -452,6 +454,7 @@ defmodule Regex do
452454
"(?imsx:foo\\n)"
453455
454456
"""
457+
@doc since: "1.19.0"
455458
@spec to_embed(t, [term]) :: String.t()
456459
def to_embed(%Regex{source: source, opts: regex_opts}, embed_opts \\ []) do
457460
strict = Keyword.get(embed_opts, :strict, true)
@@ -471,9 +474,7 @@ defmodule Regex do
471474
end
472475
end
473476

474-
disabled =
475-
Enum.reject([?i, ?m, ?s, ?x], &(&1 in modifiers))
476-
|> List.to_string()
477+
disabled = List.to_string([?i, ?m, ?s, ?x] -- modifiers)
477478

478479
disabled = if disabled != "", do: "-#{disabled}", else: ""
479480

0 commit comments

Comments
 (0)