๐Ÿงช

Regex Tester

Test JavaScript regular expressions with live match highlighting, capture groups and a replace preview.

Built and maintained by Abdur Rehman ยท Free, no sign-up

Loading Regex Testerโ€ฆ
๐Ÿ”’PrivateRuns in your browser โ€” nothing is uploaded.
โšกFastInstant results, no waiting in queues.
๐Ÿ’ธFreeNo sign-up, no watermark, no limits.
๐Ÿ“ฑAnywhereWorks on phone, tablet and desktop.

How to use the Regex Tester

  1. Enter your regular expression and flags
  2. Paste a test string
  3. See matches, groups and replacements

Test regular expressions live

Type a regular expression and its flags (g, i, m, s, u, y), and every match in your test text is highlighted as you type, with a match count and a table of capture groups. Add a replacement (using $1 or $<name>) to preview the result. Ready-made patterns for email, URL, phone, date, IPv4, hex colour and numbers get you started. Everything runs in your browser.

JavaScript behaviour

The tester uses the browser's JavaScript engine, so results match JavaScript exactly โ€” named groups, lookbehind and Unicode property escapes such as \p{L} all work.

Other languages

Everyday syntax โ€” character classes, quantifiers, groups, alternation, anchors โ€” works the same in Python, Java, C#/.NET, PowerShell and R. Watch for these differences:

  • Python writes named groups as (?P<name>โ€ฆ); use (?<name>โ€ฆ) here.
  • Java and .NET support possessive quantifiers and atomic groups, which JavaScript doesn't.
  • sed and grep use POSIX regex, which has no \d or lookarounds โ€” use [0-9] instead.

Useful patterns

  • Whole numbers: ^\d+$; decimals: -?\d+(\.\d+)?
  • Anything that isn't a letter, digit or space: [^a-zA-Z0-9\s]

Quick reference

PatternMatches
\d \w \sA digit, a word character (letter, digit, underscore), whitespace
.Any character except a line break (with the s flag, line breaks too)
[abc] [^abc]One of a, b or c; anything except a, b or c
* + ? {2,5}0 or more, 1 or more, optional, between 2 and 5 times
^ $ \bStart of text, end of text, a word boundary
(โ€ฆ) (?:โ€ฆ) (?<name>โ€ฆ)Capture group, group without capturing, named group
(?=โ€ฆ) (?!โ€ฆ) (?<=โ€ฆ)Followed by, not followed by, preceded by

Flags

g finds every match instead of the first one. i ignores case. m makes ^ and $ match at the start and end of each line. s lets . match line breaks. u turns on full Unicode, needed for \p{L}. y only matches at the exact position where the last match ended, and d records where each group starts and ends.

Common mistakes

  • Greedy matching. <.+> on "<b>hi</b>" matches the whole string. Add ? to make it lazy: <.+?> matches each tag separately.
  • Unescaped dots. example.com also matches "exampleXcom". Write example\.com.
  • Only one match. Without the g flag, only the first match is found and replaced.

Frequently asked questions

Why does my regex only find the first match?

The g (global) flag is missing. Add g in the Flags box to find and replace every match.

How do I match across several lines?

Use the m flag so ^ and $ work on every line, and the s flag if you need . to match line breaks as well.

Is this the same as regex in Python?

Mostly. Everyday patterns work the same, but Python writes named groups as (?P<name>...) and has some differences in flags. This tester follows JavaScript exactly.

๐Ÿ’ป Keep exploring Developer Tools

See all Developer Tools