Advertisement
top slot

Regex Tester

Test patterns + cheatsheet

Productivity

Regex Tester

Test patterns + cheatsheet

Advertisement
top slot
/ /
Cheatsheet
. any char (no \n)
\d digit
\w word char
\s whitespace
^ $ line anchors
\b word boundary
+ * ? one+ / zero+ / opt
{n,m} repeat range
(...) capture group
(?:...) non-capturing
(?<n>...) named
(?=...) lookahead
[abc] [^abc] set / negate
a|b alternation

About Regex Tester

What a regular expression is

A regular expression (regex / regexp) is a tiny pattern-matching language. The pattern \d{3}-\d{4} matches 555-1212. The pattern ^https?:\/\/[\w.-]+\.[a-z]{2,}\b matches a URL. Regex is supported in every programming language, every text editor, and most CLI tools (grep, sed, awk) — once you know it, it follows you everywhere.

Regex is also famously easy to get subtly wrong. A pattern that looks right often greedy-matches more than you want, or misses Unicode characters, or doesn't anchor properly. A live tester is the standard way to write regex: paste the input you actually have, type the pattern, see what matches in real time.

What this tool does

  • Live matching as you type. Matches are highlighted in the input; capture groups appear in a side panel.
  • All standard flagsg (global), i (case-insensitive), m (multiline ^ and $), s (dotall), u (Unicode), y (sticky).
  • Named capture groups ((?<name>…)) are extracted and labelled.
  • Find-and-replace preview. Type a replacement string with $1, $<name>, etc. and see the output side-by-side.
  • Cheatsheet panel with the syntax reference open. No more popping between three tabs.
  • JavaScript flavour. The engine is the browser's built-in RegExp, so what you see here matches what your JS code will see at runtime. (PCRE / Python flavour differences are noted in the cheatsheet.)
  • Browser-only. Paste sensitive logs, API responses, or credentials — nothing uploads.

Common patterns to copy

  • Email (rough): ^[^\s@]+@[^\s@]+\.[^\s@]+$ — good enough for most form validation. Don't try to write RFC 5322-compliant; that pattern is famously ~6000 characters long.
  • URL: ^https?:\/\/[\w.-]+\.[a-z]{2,}(\/.*)?$ — http or https, domain, optional path.
  • US phone: \(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4} — handles 555-555-5555, (555) 555-5555, 555.555.5555.
  • ISO 8601 date: ^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$ — strict YYYY-MM-DD with valid months and days.
  • IPv4: ^(\d{1,3}\.){3}\d{1,3}$ (loose) or ^((25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d)$ (strict).
  • Hex color: ^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$.
  • UUID v4: ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$.

When NOT to use regex

  • Parsing HTML. Use a real HTML parser (DOMParser, cheerio, BeautifulSoup). Regex breaks on every edge case.
  • Parsing JSON / YAML / TOML. Use a real parser; the Toolenza json and data-convert tools.
  • Anything with nested structures. Regex is regular — it can't count balanced parens.
Advertisement
in-content slot

Frequently asked questions

JavaScript (ECMAScript). The engine is the browser's built-in RegExp, so patterns behave exactly as they will in JS code. Most basic syntax is identical across JS, PCRE, Python and Go, but there are differences in lookbehind support, named-group syntax, and Unicode classes. The cheatsheet flags the JS-specific bits.

Most common reasons: (1) you didn't anchor with `^` and `$` (so a partial match counts), (2) you didn't use the `g` flag and only see the first match, (3) you didn't escape a special character (`.` matches any char, not a literal dot), (4) greedy quantifiers (`.*`) match more than you wanted — try the non-greedy `.*?` version.

Wrap with `()` in the pattern. Use `$1`, `$2`, etc. in the replacement. For named groups: `(?<year>\d{4})` and reference as `$<year>`.

Prefix with a backslash: `\.` matches a literal dot, `\*` matches a literal asterisk. Inside a character class `[…]` many special characters lose their meaning automatically.

No. The pattern and the test input stay in your browser. Safe for sensitive logs, API responses, and PII you're cleaning up.

Embed this tool on your site

Drop a one-line iframe snippet into any blog, lesson plan, or knowledge base. Powered-by-Toolenza link included.

Embed this tool

Paste this snippet into any HTML page. The tool runs entirely in your reader's browser.

Advertisement
bottom slot
Sticky ad — mobile-sticky

Regex Tester

No reviews yet — be the first to share your thoughts.

Your rating
  1. No reviews yet — be the first to share your thoughts.
Powered by Codenzia
Sticky ad — mobile-sticky
↑↓ navigate open
Toolenza Brain
Tip: describe a result you want, not a tool. The Brain picks for you.
⌘⇧K to open · esc to close
Thanks! We read every message.