LazyTools

🔒 Every tool runs in your browser, the files and values you enter are never uploaded to any server. How it works

🧩 Regex Tester

Type a pattern, paste test text, see every match with its position and capture groups, updated on every keystroke.

2 matches

Rate this tool:
Anonymous, no account, no identifier

How the regex tester works

The pattern runs as a real JavaScript RegExp against your text, listing each match with its index and any capture groups, the exact behavior your JS code will see, because it is the same engine. Flags work as in code: g (all matches, applied automatically), i (case-insensitive), m (multiline ^ $), s (dot matches newline), u (unicode). The index reported for each match is the zero-based character position where it starts, and capture groups are numbered left-to-right by the order their opening parenthesis appears, so in (\w+)@(\w+) group 1 is the text before the @ and group 2 the text after.

Testing here mirrors JavaScript exactly, which is both the feature and the caveat: JS regex differs from PCRE/Python in places (lookbehind support, named groups syntax, no possessive quantifiers). For patterns destined for another language, verify in that ecosystem too.

Frequently asked questions

Which regex flavor is this?

JavaScript (ECMAScript), the same engine as your browser and Node code. Most syntax is shared with PCRE/Python, but edge features differ; test in the target language for anything exotic.

What do the flags mean?

g = all matches, i = ignore case, m = ^ and $ match per line, s = . matches newlines, u = full Unicode. This tester always applies g so you see every match.

How do capture groups show up?

Parentheses create groups, listed per match in order, the sample splits emails into user and domain. Use (?:…) for grouping without capturing.

Why does my pattern error?

Unbalanced parentheses/brackets or a dangling quantifier, usually. The error message is the engine's own. Escape literal special characters with a backslash.

What is a named capture group?

A group written (?<name>…) that you can refer to by name instead of number, for example (?<year>\d{4})-(?<month>\d{2}) exposes year and month. JavaScript supports this syntax, and matches expose the values on a groups object; the numbering of positional groups is unaffected.

How do I match a literal dot or other special character?

Escape it with a backslash: \. matches a literal period, and the same applies to * + ? ( ) [ ] { } ^ $ | \, all of which otherwise have special meaning. So to match an IP-style "1.2" you need 1\.2, since an unescaped dot matches any character.

Why does my greedy quantifier match too much?

By default * and + are greedy. They consume as much as possible, so <.+> against "<a><b>" matches the whole string. Add a ? to make them lazy (<.+?>) and each match stops at the first closing >. This is the single most common regex surprise.

What do the ^ and $ anchors match?

By default ^ matches the start of the whole string and $ the end, so ^abc$ matches only the exact string "abc". With the m (multiline) flag they instead match the start and end of each line, which is how you match line-by-line inside a multi-line block of text.

What is the difference between \d, \w and \s?

They are shorthand character classes: \d matches a digit (0-9), \w a word character (letters, digits and underscore), and \s any whitespace (space, tab, newline). Their uppercase forms \D, \W and \S match the exact opposite, anything that is not in that set.

Is my test data private?

Yes, matching runs locally. Paste logs and real data freely; nothing is transmitted.

Related developer tools