Regex Generator
Build a safe regular expression from curated patterns.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Generated the pattern /^(?:[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,})$/i.
How it works
- Selected the curated Email address pattern.
- Anchored the pattern to the whole string.
- Composed the flags "i".
- Verified the pattern has no nested quantifiers, backreferences or lookbehind.
^(?:[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,})$- Curated patterns are reviewed linear-time grammars.
- The generator does not infer patterns from example text, because inference can produce dangerous backtracking.
Methodology
- Select a reviewed pattern from the curated catalogue, or escape the custom literal.
- Wrap the pattern in a non-capturing group and add anchors when requested.
- Compose the i, g and m flags from the selected options.
- Confirm the result contains no nested quantifier, backreference or lookbehind.
Usage
- Choose a pattern kind, or custom-literal and enter the literal text.
- Choose anchors and flags.
- Run the tool, then copy the pattern and flags into your code.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Anchored email
{
"kind": "email",
"literal": "",
"anchors": true,
"caseInsensitive": true,
"global": false,
"multiline": false
}Escaped literal
{
"kind": "custom-literal",
"literal": "a.b*c",
"anchors": true,
"caseInsensitive": false,
"global": false,
"multiline": false
}Global UUID
{
"kind": "uuid",
"literal": "",
"anchors": false,
"caseInsensitive": false,
"global": true,
"multiline": false
}Limitations
Safe by construction
A generator that emits arbitrary patterns can hand you a regular expression that hangs on hostile input. Keeping the catalogue small and reviewed, and escaping custom literals exactly, removes that class of failure.
Frequently asked questions
- What is ReDoS?
- Regular expression denial of service is caused by patterns that can backtrack exponentially on certain input, such as nested quantifiers. The curated patterns avoid that shape and are reviewed as linear-time.
- Why not generate a regex from my sample strings?
- Inferring a pattern from examples tends to produce broad, backtracking-prone expressions. This tool favours a small set of reviewed safe patterns and an exact escaped literal instead.
Sources
- ECMA-262: ECMAScript Language Specification — RegExp — Ecma International
- MDN Web Docs — RegExp — Mozilla
- OWASP — Regular expression Denial of Service — OWASP
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.