Skip to content

aivi.regex ​

Compiler-backed regular-expression search and replacement. Patterns use Rust regex syntax, and ordinary AIVI string escaping still applies.

The MVP keeps one canonical name for each operation. Application-specific validation policy, such as what counts as an email address or URL, belongs in application code.

aivi
use aivi.regex (
    Pattern
    RegexError
    isMatch
    find
    findText
    findAll
    replace
    replaceAll
)

Types ​

TypeMeaning
PatternAlias for regex pattern text
RegexErrorDescriptive error text returned when a pattern is invalid

Operations ​

FunctionTypeResult
isMatchPattern -> Text -> Task RegexError BoolWhether the text contains a match
findPattern -> Text -> Task RegexError (Option Int)Character index of the first match
findTextPattern -> Text -> Task RegexError (Option Text)Text of the first match
findAllPattern -> Text -> Task RegexError (List Text)All non-overlapping matched snippets
replacePattern -> Text -> Text -> Task RegexError TextReplace the first match
replaceAllPattern -> Text -> Text -> Task RegexError TextReplace every non-overlapping match

The replacement argument comes before the input text. A valid pattern with no match succeeds with False, None, an empty list, or the unchanged input, depending on the operation. An invalid pattern fails the task with RegexError.

aivi
use aivi.regex (isMatch)

value hasDigits : Task Text Bool = isMatch "[0-9]+" "room 42"

(c) 2026 by Andreas Herd