@@ -10,13 +10,12 @@ defmodule Regex do
1010 # A simple regular expressions that matches foo anywhere in the string
1111 %r/foo/
1212
13- # A regular expression with case insensitive options and handling for unicode chars
14- %r/foo/iu
13+ # A regular expression with case insensitive options
14+ %r/foo/i
1515
1616 The `re` module provides several options, the ones available in Elixir, followed by
1717 their shortcut in parenthesis, are:
1818
19- * `unicode` (u) - enables unicode specific patterns like \p
2019 * `caseless` (i) - add case insensitivity
2120 * `dotall` (s) - causes dot to match newlines and also set newline to anycrlf.
2221 The new line setting can be overridden by setting `(*CR)` or `(*LF)` or
@@ -75,7 +74,9 @@ defmodule Regex do
7574 { :error , { :invalid_option , rest } }
7675
7776 translated_options ->
78- compile ( source , translated_options , options )
77+ # Always use the unicode option, we don't have a latin1 legacy like
78+ # Erlang.
79+ compile ( source , [ :unicode | translated_options ] , options )
7980 end
8081 end
8182
@@ -367,7 +368,10 @@ defmodule Regex do
367368 defp return_for ( element ) when is_binary ( element ) , do: :binary
368369 defp return_for ( element ) when is_list ( element ) , do: :list
369370
370- defp translate_options ( << ?u , t :: binary >> ) , do: [ :unicode | translate_options ( t ) ]
371+ defp translate_options ( << ?u , t :: binary >> ) do
372+ IO . write "The /u flag for regular expressions is no longer needed\n #{ Exception . format_stacktrace } "
373+ translate_options ( t )
374+ end
371375 defp translate_options( << ?i , t :: binary >> ) , do: [ :caseless | translate_options ( t ) ]
372376 defp translate_options ( << ?x , t :: binary >> ) , do: [ :extended | translate_options ( t ) ]
373377 defp translate_options ( << ?f , t :: binary >> ) , do: [ :firstline | translate_options ( t ) ]
0 commit comments