Elixir Language Custom sigils


Custom sigils can be made by creating a method sigil_X where X is the letter you want to use (this can only be a single letter).

defmodule Sigils do
  def sigil_j(string, options) do
    # Split on the letter p, or do something more useful
    String.split string, "p"
  # Use this sigil in this module, or import it to use it elsewhere

The options argument is a binary of the arguments given at the end of the sigil, for example:

~j/foople/abc # string is "foople", options are 'abc'
# ["foo", "le"]