AI Regex Generator
Natural language to regex — on-device WebLLM
Describe the pattern
Examples
Named path segment
Match a GitHub branch name like feature/finetuned-ai-tool-modelsDescribes shape plus a concrete example — the most reliable phrasing for this model.
Doubled word
Find duplicate words like 'the the' in a sentenceBackreference pattern; verify in Regex Tester — small models often drop the capture group.
ISO date
Match an ISO 8601 date such as 2026-08-21Fixed-format matching; ask for exact digits, not ranges, for best results.
URL capture
Capture the domain from URLs like https://example.com/pathAsks for a capture group explicitly so the model anchors on the scheme.
About this tool
Natural language to JavaScript regex with link to Regex Tester for validation.
How to use
Describe the pattern
Say what should match and, ideally, give one or two examples.
Pick a model
Quality (1.5B) handles anchors and groups more reliably.
Generate
Get a JavaScript RegExp with a short explanation.
Test it
Open the linked Regex Tester and check positive and negative cases.
Use cases
Draft without syntax recall
Describe the intent, get a starting pattern instead of re-learning regex syntax.
Form validation
Quick patterns for emails, slugs, dates and other input checks.
Learning by comparison
Compare the generated pattern with your own attempt to spot missed anchors or groups.
Common mistakes
Mistake:Expecting PCRE-only constructs.
Fix:Output targets JavaScript RegExp — recursion and possessive groups do not translate.
Mistake:No negative examples in the prompt.
Fix:Say what should NOT match; otherwise the pattern is often too loose.
Mistake:Nesting quantifiers on long inputs.
Fix:Patterns like (a+)+ on large text can backtrack catastrophically — test with realistic length.
Frequently asked questions
References & standards
Related tools
AI Code Explainer
Explain code snippets with on-device WebLLM
AI Commit Message Generator
Suggest Conventional Commits messages from a git diff using on-device WebLLM
AI Documentation Generator
Generate JSDoc/TSDoc blocks from code with on-device WebLLM
AI SQL Query Generator
Generate SQL from natural language with on-device WebLLM and sql-formatter output
Context Assembler
Combine files and folders into one LLM-ready context block with XML tags, a project tree, ignore filters and a token estimate — like repomix or files-to-prompt, in your browser.
LLM Token Counter
Visualize BPE tokens with color blocks, model selector, and per-request cost estimate