Otter
Snippets
Otter
Upstream Otter 1.0.1 Tested
Replace Text Substrings
Replace matching substrings with replacement text inside variable.
Architecture & Runtime Preview
Otter 1.0.1Zero-dependency Otter 1.0.1 snippet (Text & Strings). Copy the parameterized template or run the self-contained example.
- 1Category: Text & Strings
- 2Attribution: Otter Core Language Spec (D27)
- 3Zero external pack dependencies — paste directly into any .ot file
Source Code (2 files)
replace "${findText}" with "${replacementText}" in ${targetVariable}
greeting is "Hello world! Welcome to world."
replace "world" with "Otter" in greeting
say greeting
if greeting is not "Hello Otter! Welcome to Otter."
fail with "text replacement mismatch"
.
Installation & Usage
otter snippet inspect text-replace-all
Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.