regex-vs-llm-structured-text

Parses structured text with regex and routes low-confidence extractions to LLM validation.

Updated May 19, 2026
One-click install
npx skills add https://github.com/azusagasaku/--claude-config --skill regex-vs-llm-structured-text-azusagasaku
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: regex-vs-llm-structured-text
Source: https://github.com/azusagasaku/--claude-config/tree/main/skills/ecc/regex-vs-llm-structured-text
Command: npx skills add https://github.com/azusagasaku/--claude-config --skill regex-vs-llm-structured-text-azusagasaku

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Parsing structured text like quizzes, forms, and invoices with LLMs alone is expensive and slow, while regex alone breaks on edge cases. This Skill provides a decision framework and hybrid pipeline that uses regex for the 95-98% of cases it handles deterministically and reserves cheap LLM calls only for low-confidence extractions. ## Core Features & Use Cases - Decision Framework: A flowchart for choosing regex, LLM, or a hybrid approach based on how consistent and repeating the text format is. - Hybrid Pipeline Architecture: Regex parser, text cleaner, confidence scorer, and LLM validator stages with a 0.95 confidence threshold for flagging edge cases. - Production Metrics: Real-world results from a 410-item quiz parsing pipeline showing 98% regex success rate and roughly 95% cost savings versus an all-LLM approach. - Use Case: Parse 410 exam questions from a document with regex, flag the 8 low-confidence items via confidence scoring, and send only those to a Haiku-class model for correction. ## Quick Start Ask the AI to parse a structured document such as a quiz or invoice using regex first and validate only the low-confidence items with an LLM.

Frequently Asked Questions about regex-vs-llm-structured-text

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I parse structured text with regex in Python?▼

Use re.compile with named groups and MULTILINE/DOTALL flags to match repeating patterns like numbered questions, choices, and answers. Iterate with finditer to build immutable dataclass instances for each parsed item.

When should I use regex vs LLM for text extraction?▼

Use regex when over 90% of the text follows a consistent repeating pattern, since it handles 95-98% of cases cheaply and deterministically. Use an LLM directly only for free-form, highly variable text with no stable structure.

How do I reduce LLM costs when parsing documents?▼

Run regex extraction first, score each result's confidence, and send only items below a 0.95 threshold to the cheapest available model such as Claude Haiku. Production metrics show this cuts costs by roughly 95% versus sending everything to an LLM.

How do I detect bad regex extractions automatically?▼

Apply confidence scoring that deducts points for signals like fewer than three choices, missing answers, or suspiciously short text. Items scoring below the threshold are flagged and routed to LLM validation.

What are the limitations of regex-based text parsing?▼

Regex fails on free-form or highly variable text and on malformed input, missing fields, and encoding issues. It also breaks silently without confidence scoring, so untested edge cases can produce wrong extractions that go unnoticed.