regex
Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.
Compile ข้อความ patterns to regex via ↦ regex.
Syntax: <ข้อความ> ↦ regex
Category#
literal
Related#
Examples#
radix/corpus/literalia/regex.fab (canonical · conversio)#
Compile ข้อความ patterns to regex via ↦ regex.
# =============================================================================
# regex — Compile ข้อความ patterns to regex via ↦ regex.
# =============================================================================
#
# What this teaches:
# • converting ข้อความ strings to compiled regex with `↦ regex`
# • inline regex flags like `(?i)` for case-insensitive matching
# • combining `§` template application with regex แปลง for dynamic patterns
#
# Common mistakes:
# • Forgetting that ↦ regex requires a ข้อความ or ascii source — จํานวน and other types must convert to ข้อความ first.
#
# See also: อ่าน, การแปลง, จารึก
# =============================================================================
# literalia/regex — ข้อความ ↦ regex การแปลง
#
# GRAMMAR:
# การแปลง :← stringLit '↦' 'regex'
# templateExpr :← stringLit '(' exprList ')' -- then ↦ regex on the ข้อความ result
#
# EXPECTED OUTPUT:
# Regex pattern diagnostics for literals, inline flags, and a template-built path.
#
# BACKEND:
# Cross-ref อ่าน/lege.fab for regex beside stdin reads.
# Cross-ref จารึก/scriptum.fab for § template application.
main {
const regex digits ← "\d+" ↦ regex
print digits
const regex word ← "(?i)\w+" ↦ regex
print word
# Template application → ข้อความ, then การแปลง to regex (dynamic path segments)
const string tenant ← "acme"
const regex homePath ← "/home/§/.*"(tenant) ↦ regex
print homePath
}Expected output:
\d+
(?i)\w+
/home/acme/.*