Algorithms · real, tested code

Match a Regular Expression in Larzscript

Test, extract, and replace with a real (if deliberately small) regex engine - literals, classes, quantifiers, anchors.

regex is a minimal backtracking engine built on native regex_match/find/replace/split primitives - no capture groups or alternation, but real character classes and quantifiers for the validation/cleanup patterns most scripts actually need.

larzscript pkg install regex

Code

import "regex" as regex

print(regex.test("[0-9]+", "order #4821"))
print(regex.matched_text("[0-9]+", "order #4821"))
print(regex.replace("[^a-z0-9]+", "Hello, World!".lower(), "-"))
Output
true
4821
hello-world-