O'Reilly logo

Elixir Cookbook by Paulo A Pereira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Strings and Binaries

This chapter will cover the following recipes:

  • Joining strings
  • Splitting strings
  • Replacing string codepoints with patterns
  • Slicing strings with ranges
  • Using regular expressions
  • Combining operations with the |> operator
  • Creating a word list
  • Determining the word frequency in a text
  • Reading and writing metadata from MP3 files

Introduction

In Elixir, strings are declared using double quotes ("") and they are, by default, UTF-8-encoded binaries. A group of bytes represent each codepoint in a string.

Note

A codepoint, in this context, is the binary representation of a UTF-8-encoded character.

Elixir's support for strings is excellent. However, remember that under the hood, they are binaries!

Note

In order to represent some characters ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required