Document brace escaping in Text.matches patterns #31
closed
@chrismichaelps wrote on 2026-09-28
Observed while smoke-testing 0.1.0 in a scratch project: TextRule.matches(builder, \"^[A-Z]{2}-[0-9]{4}$\") failed to match \"AB-1234\".
Reproduction: pass the pattern above to Text.matches, validate a matching value, check isValid.
Analysis: not a defect in matches. Pudu string literals interpolate {...}, so the pattern arrived at the regex engine as ^[A-Z]2-[0-9]4$. Writing the pattern with escaped braces (\"^[A-Z]\\{2\\}-[0-9]\\{4\\}$\") matches correctly.
Action: document the escaping rule for regex patterns in the wiki (Built-In-Checks) and/or the matches doc comment, so readers do not trip on it.
Read and reply on GitHub ↗1 comment continue on GitHub.
