regex
Technical notes on web development, DevOps, and AI integration.
5 articles
- 22:20tooling
When Browser Automation Selectors Break on Locale Switches
My automation browser profile leaked an id-ID locale, the UI rendered Tanya Qwen instead of Ask Qwen, and every exact-label selector quietly broke. Here is the two-layer fix.
TL;DR: An automation suite broke because the browser profile's id-ID locale made the target site render UI text in Indonesian, so exact-match selectors like "Ask Qwen" failed. The fix: regex alternation accepting both languages, plus pinning the locale via context emulation. A small assert-based test guards against regressions.
#automation#playwright#regex - 13:22tooling
AI Chat Scraper Audit: From False Positives to Precise Regex
A loose completion gate called a half-written answer done. One audit produced four fixes: pre-answer failure patterns, an anchored heading gate, probe-copy.
TL;DR: The scraper kept cutting AI answers short because loose completion gates matched "Sources" inside citation lines. The fix narrows trust: failure patterns only count before any answer text, and the completion gate requires a contracted final heading via a strict regex. Added a --probe-copy diagnostic and evidence logging; selftest grew from 72 to 79 asserts.
#python#regex#debugging - 16:51backend
The Marker That Hid Between Two Chunks
A correct regex run against stream fragments matches nothing when the marker spans two deltas. Strip the joined answer instead.
TL;DR: A CTA_FLAG marker leaked into a Redis-cached chat answer because the model split it across two stream chunks, so the per-delta regex strip never matched a full pattern. The fix adds a cleanup pass on the joined answer right before caching. Lesson: any regex run per-chunk is blind to split patterns, so sanitize at the last point before persistence.
#sse#streaming#regex - 15:39ai
That Time a Control Flag Showed Up in the Chat Bubble
A raw CTA_FLAG: YES marker leaked into a live chat bubble. The strip regex only matched end-of-string, and the SSE stream bypassed it entirely.
TL;DR: A CTA_FLAG marker leaked into the UI because the model ignored placement instructions and SSE streaming sent chunks before the strip regex ran. The fix moved CTA data into a structured field on the knowledge source, rendered directly by the frontend. Lesson: never parse UI-critical data out of model prose; use structured fields.
#llm#streaming#sse - 00:00frontend
Code Blocks Rendering Twice: How a JavaScript Regex Can Race
A double code block bug on the blog: a module-level /g regex's lastIndex gets clobbered across parallel async calls. The fix is eight lines.
#javascript#regex#shiki