Skip to content

Instantly share code, notes, and snippets.

@Gazler
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gazler/8c893bbcfad2d09a0dd0 to your computer and use it in GitHub Desktop.
Save Gazler/8c893bbcfad2d09a0dd0 to your computer and use it in GitHub Desktop.
Elixir Regex split
gazler@gazler-desktop-pc:~/development/elixir/elixir$ iex
Erlang/OTP 17 [erts-6.0] [source-07b8f44] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (0.14.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Regex.split(~r/(%{[^}]+})/, "%{foo}(%{bar}): %{baz}")
["", "%{foo}", "(", "%{bar}", "): ", "%{baz}", ""]
gazler@gazler-desktop-pc:~/development/elixir/elixir$ iex
Erlang/OTP 17 [erts-6.0] [source-07b8f44] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (0.15.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Regex.split(~r/(%{[^}]+})/, "%{foo}(%{bar}): %{baz}")
["", "(", "): ", ""]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment