Testador de Regex

O Testador de Regex é uma ferramenta essencial para desenvolvedores e analistas de dados que trabalham com padrões de texto. Ele permite que você crie, teste e depure suas expressões regulares em tempo real, garantindo que elas funcionem como esperado. Simplifique a validação de dados e a extração de informações com esta ferramenta prática.

Regular expression quick reference

A regular expression (regex) is a pattern that describes a set of strings. They are used in search, validation, and text transformation across every programming language. JavaScript regex patterns are written between forward slashes: /pattern/flags.

TokenMeaningExample
.Any character except newline/h.t/ → hat, hit, hot
\dAny digit 0–9/\d+/ → 42, 100
\wWord char (a-z, A-Z, 0-9, _)/\w+/ → hello_world
^Start of string/^Hello/ → Hello world
$End of string/world$/ → Hello world
*0 or more/ab*c/ → ac, abc, abbc
?0 or 1 (optional)/colou?r/ → color, colour
+1 or more/\d+/ → 1, 42, 999

Como usar

  1. 1

    1. Insira sua expressão regular no campo 'Padrão Regex'.

  2. 2

    2. Cole o texto que deseja testar no campo 'Texto de Entrada'.

  3. 3

    3. Observe os resultados em tempo real, com as correspondências destacadas.

  4. 4

    4. Ajuste sua expressão regular conforme necessário para refinar os resultados.

  5. 5

    5. Copie as correspondências ou o texto modificado para usar em seus projetos.

Perguntas frequentes

Ratings & Reviews

Rate this tool

Sign in to rate and review this tool.

Loading reviews…

What a Regex Tester Does

A regular expression (regex) is a pattern for matching strings of text. \d+ matches one-or-more digits. [a-z]{3,5} matches 3-5 lowercase letters. Regexes power form validation, search-and-replace, log parsing, URL routing, and much more — but they're notoriously hard to write correctly without testing.

The Microapp Regex Tester lets you write a regex and test it against sample text in real time. Matches highlight in the input as you type. Shows capture groups, supports all standard JavaScript regex flags, and runs entirely in your browser — your patterns and test text never leave your device.

How to Use It

  1. Enter your regex pattern in the pattern input (without surrounding slashes — flags go in the separate flags field).
  2. Enter or paste sample text into the test area.
  3. Matches highlight as you type. Capture groups appear below.
  4. Toggle flags as needed: g (global, find all), i (case-insensitive), m (multiline), s (dotall), u (unicode), y (sticky).
Worked example. Pattern: (\w+)@(\w+\.\w+) with flag g
Text: Email me at [email protected] or [email protected]
Matches: [email protected], [email protected]
Capture group 1: usernames (alice, bob). Capture group 2: domains (example.com, test.org).

The Most-Used Regex Patterns

What you want to matchPatternNotes
Any digit\dEquivalent to [0-9]
Any letter[a-zA-Z]\w matches word chars (letters + digits + _)
One or more+\d+ = at least 1 digit
Zero or more*\d* = 0+ digits
Optional?colou?r matches both color and colour
Exact count{n}\d{4} = exactly 4 digits (e.g. years)
Range{n,m}\d{3,5} = 3 to 5 digits
Beginning of line^With m flag, matches start of every line
End of line$With m flag, matches end of every line
Capture group( )Captured text accessible as $1, $2, etc.
Non-capturing group(?: )Group for alternation/grouping without capturing
Alternation|cat|dog matches cat or dog
Word boundary\b\bword\b matches word as a whole word

Common Regex Mistakes

Forgetting to escape special characters. ., *, +, ?, (, ), [, ], {, }, ^, $, |, \ all have special meaning. To match them literally, escape with backslash: \. matches a literal period.

Greedy vs lazy matching. .* is greedy — matches as much as possible. .*? is lazy — matches as little as possible. The difference matters in HTML parsing or any text with multiple potential closing markers.

Email validation overkill. The "perfect" email regex is hundreds of characters and still doesn't match every edge case. For practical validation, use ^[^\s@]+@[^\s@]+\.[^\s@]+$ (no spaces, has @, has a dot in the domain) and verify with an actual confirmation email.

Anchors and the m flag. Without m, ^ matches only the start of the entire input. With m, it matches the start of each line. Forgetting m when working with multiline input is a common bug.

When Regex Is the Wrong Tool

Regex is great for pattern matching in roughly-structured text. It's bad at:

  • Parsing HTML. HTML can nest arbitrarily; regex can't handle nested structures. Use a real HTML parser (cheerio, jsdom, BeautifulSoup).
  • Parsing JSON, XML, CSV. Same reason — these have structure that regex can't reliably model. Use JSON.parse, an XML parser, or a CSV parser.
  • Handling natural-language ambiguity. Don't try to regex your way through prose. Use NLP libraries.

Related Tools

For testing and formatting JSON data alongside regex work, use the JSON Formatter. For URL-encoding strings to embed in regex patterns or test data, see the URL Encoder/Decoder. For converting case (often needed before regex matching with the i flag isn't enough), the Case Converter is the right tool.