0Pricing
Elixir & Phoenix: Scalable Backend Development · Lektion

Strings, Binärdaten und Sigils in Elixir

Erkunden Sie, wie Elixir Text als UTF-8-Binärdaten darstellt, und verwenden Sie Sigils, um Strings, Listen und reguläre Ausdrücke kompakt zu schreiben.

Strings, Binärdaten und Sigils in Elixir ist eine kostenlose Elixir & Phoenix: Scalable Backend Development-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Elixir & Phoenix: Scalable Backend Development-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Elixir & Phoenix: Scalable Backend Development-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Strings Are UTF-8 Binaries

An Elixir string is a UTF-8 binary in double quotes — not a list of characters. Keep that distinction in mind.

name = "Elixir"
IO.puts(name)

String Concatenation

Join two strings with <>, which concatenates the underlying binaries.

greeting = "Hello, " <> "World"
IO.puts(greeting)

String Interpolation

Drop expressions into a string with interpolation: the code is evaluated and its result slotted in.

name = "Ada"
IO.puts("Hello, #{name}!")

Common String Functions

The String module is full of helpers for transforming text, like upcase and length.

IO.puts(String.upcase("elixir"))
IO.puts(String.length("hello"))

Splitting and Trimming

Use String.split to break text into parts and String.trim to strip surrounding whitespace.

parts = String.split("a,b,c", ",")
IO.inspect(parts)
IO.puts(String.trim("  hi  "))

Strings vs Charlists

Single quotes make a charlist — a list of integers — not a string. Most modern APIs expect double-quoted strings.

IO.inspect('abc')
IO.inspect("abc")

Introducing Sigils

A sigil starts with ~ and a letter for compact literals. For example, ~s builds a string.

text = ~s(He said "hi")
IO.puts(text)

Word List Sigils

The ~w sigil builds a word list from whitespace-separated text — no noisy quotes or commas.

words = ~w(apple banana cherry)
IO.inspect(words)

Atom Word Lists

Append the a modifier to ~w and you get a list of atoms instead of strings.

keys = ~w(name age email)a
IO.inspect(keys)

Regex Sigils

The ~r sigil creates a regex, which you pair with the Regex module to match and replace.

IO.inspect(Regex.run(~r/\d+/, "abc123"))

Heredocs for Multiline Text

Triple-quoted heredocs hold multi-line text and double as documentation strings.

msg = """
Line one
Line two
"""
IO.puts(msg)

Quick Check

Test your Elixir string knowledge.

Recap

Recap: strings are UTF-8 binaries you join with <> and interpolate; the String module transforms them; charlists differ; and sigils keep literals concise.

Häufig gestellte Fragen

Ist die Lektion „Strings, Binärdaten und Sigils in Elixir“ kostenlos?

Ja — der vollständige Text von „Strings, Binärdaten und Sigils in Elixir“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Elixir & Phoenix: Scalable Backend Development-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Elixir & Phoenix: Scalable Backend Development-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Strings, Binärdaten und Sigils in Elixir“?

Erkunden Sie, wie Elixir Text als UTF-8-Binärdaten darstellt, und verwenden Sie Sigils, um Strings, Listen und reguläre Ausdrücke kompakt zu schreiben. Du übst Elixir & Phoenix: Scalable Backend Development mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Elixir & Phoenix: Scalable Backend Development zu starten?

Keine Vorkenntnisse erforderlich. Elixir & Phoenix: Scalable Backend Development auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Strings, Binärdaten und Sigils in Elixir“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Elixir & Phoenix: Scalable Backend Development-Lektion Code schreiben und ausführen?

Ja. Jede Elixir & Phoenix: Scalable Backend Development-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Einführung in die Sprache Elixir
  2. Grundlegende Datentypen und Operatoren
  3. Pattern Matching und Kontrollfluss
  4. Strings, Binärdaten und Sigils in Elixir
← Zurück zu Elixir & Phoenix: Scalable Backend Development