Elixir supports regular expressions via Erlang's
re module. This is one of those situations that we mentioned in the Using Erlang from Elixir recipe in Chapter 1, Command Line. However, we don't have to use the
re Erlang module directly! We have the Elixir
Regex module that is built on top of the Erlang module and is also based on Perl Compatible Regular Expressions (PCRE).
In this recipe, we use the
~r sigil to define regular expressions and operate on strings.
~r sigil is a special form that allows for the creation of regular expressions as alternatives to the
Internally, a regular expression is represented by the Regex struct (
Start a new IEx session by entering ...