Pular para o conteúdo
Tool

Regular Expression Tester (Regex)

Test and validate your regular expressions (Regex) in real time against example texts.

What it is

The Regex Tester lets you write a regular expression and see, live, what it matches inside a block of text, with every match highlighted and each capture group listed.

Why testing beats guessing

A regular expression is dense, and a small mistake changes the meaning entirely rather than producing an error. . matches any character, so an unescaped dot in an email pattern quietly matches far more than you intended. + and * are greedy by default and will swallow as much as they can, which is why a pattern meant to grab one HTML tag grabs the whole line.

None of that announces itself. The pattern runs, returns something, and the something is wrong. Seeing the highlights on real text is the only quick way to catch it.

The pieces worth knowing

  • \d a digit, \w a word character, \s whitespace.
  • + one or more, * zero or more, ? optional.
  • {2,4} between two and four times.
  • ^ start, $ end.
  • ( ) a capture group, which is what lets you extract or reorder parts of the match.
  • +? and *? make a quantifier lazy, taking as little as possible rather than as much.

How to use it

  1. Paste your text.
  2. Write the pattern and set the flags you need: global, case-insensitive, multiline.
  3. Read the matches and the groups.

Everything runs in your browser, so the text you paste is never sent anywhere.

Frequently asked questions

Why does my pattern match more than I expected?

Usually greediness or an unescaped dot. + and * take as much as they can, and . matches any character. Use +? for a lazy quantifier and \. for a literal dot.

What is a capture group for?

Anything inside parentheses is captured separately, which is how you extract part of a match or reorder it in a replacement, referring to the groups as $1, $2 and so on.

What do the flags do?

Global finds every match instead of just the first, case-insensitive ignores letter case, and multiline makes ^ and $ apply to each line rather than the whole text.

Which regex flavour does it use?

JavaScript's, since it runs in your browser. That matters if you are writing a pattern for another language: lookbehind, named groups and Unicode property escapes are supported in modern browsers but behave differently in older engines like PHP's or Python's.

About this content

Written by:
Ferramenta Grátis

Related tools