DevToolsForYou
Private by defaultRuns in your browser

Regex generator & tester

Pick a common pattern or write your own regex, then test it live against sample strings — matches highlighted inline.

Common patternsClick to load
/[\w.+-]+@[\w-]+\.[\w.]+/gi
Contact us at hello@example.com or support@devtools.io — invalid: @missing-local.com
Matches:hello@example.comsupport@devtools.io
Regex Gen

About this tool

Describe what you want to match in plain English, or provide positive and negative examples, and get a working regular expression instantly. Test it live against sample strings with match highlighting.

No signup requiredRuns in your browserInstant results
How to use
  1. 1

    Select a common pattern from the presets (email, URL, IP address, date, etc.) or type your own regex.

  2. 2

    Enter test strings in the Test tab — matching parts are highlighted inline.

  3. 3

    Use the Flags section to toggle global, case-insensitive, and multiline modes.

  4. 4

    Copy the final regex with the Copy button.

Why use this tool?
  • Generate an email or phone number validation regex for a form without memorising the pattern.

  • Test a regex from Stack Overflow against your actual data before adding it to code.

  • Build a URL or date pattern interactively and verify edge cases instantly.

  • Extract matches from a log snippet using the live test panel.

ExamplesInput → output

Email

InputEmail address
Output/^[\w.+-]+@[\w-]+\.[\w.]+$/i

IPv4

InputIPv4 address
Output/^(\d{1,3}\.){3}\d{1,3}$/
Common errorsAnd how to fix them

No matches found

Cause: The generated or entered regex does not match the test string — the pattern may be too strict.

Fix: Try relaxing the pattern (remove anchors ^ or $), or add more representative positive examples.

Invalid regular expression

Cause: The regex contains a syntax error such as an unescaped special character or unclosed group.

Fix: Check for unbalanced parentheses or brackets. Escape literal dots, slashes, and other special characters with a backslash.

Frequently asked questionsCommon questions answered

These answers explain common regex gen tasks, expected input formats, and edge cases so both visitors and search engines can understand what this tool does.

What presets are included?

Email, URL, IPv4, IPv6, Date (YYYY-MM-DD, DD/MM/YYYY), Time (HH:MM), Phone (international), Hex colour, Slug, Semantic version, Credit card, UUID, Postal code (US), and Integer / Float.

What flags are supported?

g (global — find all matches), i (case-insensitive), m (multiline — ^ and $ match line boundaries), and s (dotAll — dot matches newline).

Does this use AI to generate regex?

No. Patterns are pre-built, well-tested regular expressions. The tool does not call any AI or external API — everything runs in the browser.

Can I use the output in JavaScript?

Yes. The displayed regex is in JavaScript literal syntax (e.g. /pattern/flags). For other languages, remove the surrounding slashes and pass the flags separately.