Skip to content

Lua API Text

Leonard Ramminger edited this page Aug 10, 2026 · 1 revision

Lua API — Text (beez.text)

String helpers, ECMAScript regex, Prebyte templates, and line diffs.

Predicates and transforms

Function Description
contains, starts_with, ends_with boolean checks
to_lowercase, to_uppercase, to_case case changes
replace, replace_all substring replace
split, join, trim split/join/trim

Regex

beez.text.regex_match("abc123", "^abc\\d+$")
beez.text.regex_replace("foo bar foo", "foo", "baz")

Uses C++ std::regex (ECMAScript). In Lua strings, write \\d for \d.

Templates

beez.text.template("Hello {{ name }}", { name = "Beez" })

beez.text.template("{{ if ready }}yes{{ else }}no{{ endif }}", { ready = true })

-- Lua arrays use 1-based indexing in templates
beez.text.template("{{ items[1] }}", { items = { "a", "b" } })  -- "a"

Line diff

local chunks = beez.text.diff(old_text, new_text)
-- { { op = "equal"|"insert"|"delete", text = "..." }, ... }

For table diffs use beez.data.diff.


← Lua API Overview

Clone this wiki locally