Regular Expressions
A formal language for describing string matching patterns, widely used in text search, data extraction, and format validation. Regular expressions are supported by mainstream programming languages and tools.
Core Facts
Regular expressions are a pattern language specifically designed for matching, extracting, and replacing strings.
Regular expressions are widely used in text processing scenarios such as web scraping development and data cleaning.
Python provides regular expression support through the built-in re module
Timeline (last 90 days)
SQL Server 2025's T-SQL directly supports regular expression matching and replacement.
Domain-specific languages (DSLs) are programming languages designed for a specific problem domain, such as SQL for database queries, regular expressions for text matching, and Verilog for hardware description.
The regex used by the output guardrail cannot recognize numbers spelled out in words (such as twenty-two thousand), Unicode variants, or line-split fragments, nor can it distinguish legitimate numbers from quotes, so it can only serve as a last net rather than the only line of defense.
Text is scanned before the message is sent, and if the generated content contains a currency symbol or weight unit immediately adjacent to a number (₹, Rs, INR, rupees, g, gm, grams, tola), sending is blocked.
In JavaScript/TypeScript regex, ^ by default matches only the start of the string; with the m (multiline) flag added, ^ and $ match the start and end of each line.
Under the m flag of JavaScript/TypeScript regex, $ matches only the end of a line rather than the end of the string, so the \n inserted by replacement correctly forces a line break after an inline label.
The TypeScript function normalizeQuickSolutionLabel given in the original article uses the regex /^([\*\_]{2}Quick solution:[\*\_]{2})\s*(.+)$/gm to match labels wrapped in bold or underscore markers at the start of a line and force insertion of a line break.
A practical development principle is: test determinism first, then talk about prompts. If a failure reproduces stably, the problem lies in task design or tool selection rather than prompt wording, and in that case introducing regexes, parsers or structured output constraints is often more effective.
When extracting order information from WhatsApp chat logs, a single regular expression is more stable than a carefully designed prompt, especially for patterned fields such as amounts, dates and product numbers.
schemagate achieved an F1 of 0.83 in a 200-question pilot test, and 32 of the 33 false rejections stemmed from a regex bug: the check failed to correctly handle uppercase AS (such as FROM students AS T1), causing aliases to be misread as table names and the query to be rejected.
24 more timeline events
All Facts (20)
Regular expressions are a pattern language specifically designed for matching, extracting, and replacing strings.
65%VerifiedRegular expressions are widely used in text processing scenarios such as web scraping development and data cleaning.
65%VerifiedPython provides regular expression support through the built-in re module
65%VerifiedThe theoretical foundation of regular expressions comes from the theory of regular languages proposed by mathematician Stephen Kleene in the 1950s.
65%Unverified正则表达式相比AI语义理解的优势在于速度快、结果确定性高、不受上下文干扰,但对格式变化极为敏感
90%UnverifiedSQL Server 2025's T-SQL directly supports regular expression matching and replacement.
50%UnverifiedDomain-specific languages (DSLs) are programming languages designed for a specific problem domain, such as SQL for database queries, regular expressions for text matching, and Verilog for hardware description.
50%UnverifiedText is scanned before the message is sent, and if the generated content contains a currency symbol or weight unit immediately adjacent to a number (₹, Rs, INR, rupees, g, gm, grams, tola), sending is blocked.
50%UnverifiedThe regex used by the output guardrail cannot recognize numbers spelled out in words (such as twenty-two thousand), Unicode variants, or line-split fragments, nor can it distinguish legitimate numbers from quotes, so it can only serve as a last net rather than the only line of defense.
50%UnverifiedUnder the m flag of JavaScript/TypeScript regex, $ matches only the end of a line rather than the end of the string, so the \n inserted by replacement correctly forces a line break after an inline label.
50%UnverifiedThe TypeScript function normalizeQuickSolutionLabel given in the original article uses the regex /^([\*\_]{2}Quick solution:[\*\_]{2})\s*(.+)$/gm to match labels wrapped in bold or underscore markers at the start of a line and force insertion of a line break.
50%UnverifiedIn JavaScript/TypeScript regex, ^ by default matches only the start of the string; with the m (multiline) flag added, ^ and $ match the start and end of each line.
50%UnverifiedA practical development principle is: test determinism first, then talk about prompts. If a failure reproduces stably, the problem lies in task design or tool selection rather than prompt wording, and in that case introducing regexes, parsers or structured output constraints is often more effective.
50%UnverifiedWhen extracting order information from WhatsApp chat logs, a single regular expression is more stable than a carefully designed prompt, especially for patterned fields such as amounts, dates and product numbers.
50%UnverifiedRegular expressions use metacharacters (such as \d matching digits and * indicating repetition) to achieve efficient text search and replacement.
50%UnverifiedFor critical criteria, the code needs to re-read the original text and use regular expressions to search for unambiguous words for a second check.
50%UnverifiedRegex-matching the content between curly braces fails when it encounters nested objects or curly braces inside strings, so it is not a robust JSON extraction method.
50%UnverifiedRegex is a tripwire, not a wall; it can catch known phrasing families, but genuinely novel jailbreak phrasings may still pass through the input filter.
50%UnverifiedThe fixed prompt injection regex pattern is: ignore\s+(your\s+|all\s+|the\s+)?(previous\s+)?instructions, using optional capture groups to generalize the qualifiers.
50%UnverifiedThe advantage of regex filters is strong determinism, fast execution, and no need for model inference, making them suitable as the outermost first line of filtering.
50%