Renderingen-US

regex

Translation status: English reader-locale proof. Code fences render through the en pipeline; prose is canonical Latin.

Compile textus patterns to regex via ↦ regex.

Syntax: <textus> ↦ regex

Category#

literal

Examples#

radix/corpus/literalia/regex.fab (canonical · conversio)#

Compile textus patterns to regex via ↦ regex.

# =============================================================================
# regex — Compile textus patterns to regex via ↦ regex.
# =============================================================================
#
# What this teaches:
#   • converting textus strings to compiled regex with `↦ regex`
#   • inline regex flags like `(?i)` for case-insensitive matching
#   • combining `§` template application with regex conversion for dynamic patterns
#
# Common mistakes:
#   • Forgetting that ↦ regex requires a textus or ascii source — numerus and other types must convert to textus first.
#
# See also: lege, conversio, scriptum
# =============================================================================

# literalia/regex — textus ↦ regex conversio
#
# GRAMMAR:
#   conversio :← stringLit '↦' 'regex'
#   templateExpr :← stringLit '(' exprList ')'   -- then ↦ regex on the textus result
#
# EXPECTED OUTPUT:
#   Regex pattern diagnostics for literals, inline flags, and a template-built path.
#
# BACKEND:
#   Cross-ref lege/lege.fab for regex beside stdin reads.
#   Cross-ref scriptum/scriptum.fab for § template application.

main {
    const _ digits  "\d+" ↦ regex
    print digits

    const _ word  "(?i)\w+" ↦ regex
    print word

    # Template application → textus, then conversio to regex (dynamic path segments)
    const _ tenant  "acme"
    const _ homePath  "/home/§/.*"(tenant) ↦ regex
    print homePath
}

Expected output:

\d+
(?i)\w+
/home/acme/.*