regex
Translation status: हिन्दी reader-locale proof. Term names and code fences follow the hi 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/.*