Strings & Text Processing
Larz covers Larzscript's built-in string methods: changing case, measuring and slicing, joining and trimming, searching, and splitting text apart and back together.
case, length, slicing
upper() and lower() change case. len() counts characters, and you slice a string with [start:end], the same as a list:
let name = "larzscript" print(name.upper()) print(len(name)) print(name[0:5]) print(name + "!!")
Output
LARZSCRIPT 10 larzs larzscript!!
search, split, join
contains(), starts_with(), and ends_with() return true or false. split() breaks a string into a list on a separator; join() does the reverse:
let line = " apple,banana,cherry "
let clean = line.strip()
print(clean)
print(clean.contains("banana"))
print(clean.starts_with("apple"))
let parts = clean.split(",")
print(parts)
print(join(parts, " | "))Output
apple,banana,cherry true true [apple, banana, cherry] apple | banana | cherry
Every snippet on this page is run through the real larzscript interpreter, not hand-typed โ what you see in the Output blocks is the actual output, for everything shown: case conversion, slicing, concatenation, trimming, searching, splitting and joining.
Related
Lesson 7: Modules & the Package Ecosystemimport, alias, and call through it - what's next after strings.→Lesson 5: Collections โ Lists & Dictslist and dict literals, push(), len(), and for - the split() in this lesson returns exactly that kind of list.→Lesson 4: Functions & Recursionfn and return - every string method here is just a function call shaped like the ones you wrote there.→What Is Larzscript?The full explainer on the money-native pitch, for more depth than a lesson video covers.→Learn Larzscript Cookbook29 short "how to X in Larzscript" recipes, several built entirely out of string methods like these.→