Công Cụ Nhanh

Regex tester online

Flags

Catches most everyday addresses; it does not cover every case allowed by RFC 5322.

Text with matches highlighted

2 matches

Liên hệ lan.nguyen@congty.vn hoặc support+hd@example.com.vn để được hỗ trợ.

Matches

#PositionMatchGroups
18–28lan.nguyen@congty.vn—
234–59support+hd@example.com.vn—

Pattern explained, piece by piece

  1. [A-Za-z0-9._%+-]one character from [A-Za-z0-9._%+-]
  2. +↳ the previous item repeated 1 or more times
  3. @the character “@”
  4. [A-Za-z0-9.-]one character from [A-Za-z0-9.-]
  5. +↳ the previous item repeated 1 or more times
  6. \.the literal character “.” (escaped)
  7. [A-Za-z]one character from [A-Za-z]
  8. {2,}↳ the previous item repeated at least 2 times

A simple explainer to make the pattern readable, not a replacement for the regex engine.

Processed in your browser. Your files and data are never uploaded to a server.

Quick answer

A regular expression (regex) is a pattern that describes text, for example \d{3,} means “three or more digits in a row”. Type the pattern, choose flags (g to find all, i to ignore case) and paste your text: matches are highlighted instantly, with a capture-group table and a piece-by-piece explanation.

What is a regular expression?

The tester runs your pattern with the browser's own JavaScript regex engine, the same one used by JavaScript, TypeScript and Node.js, so what you see is what your code will get. As you type, matches are highlighted, the table lists each position and capture group ($1, $2, named groups), and the replace box shows the text after substitution. Patterns run in a Web Worker with a 1.5-second limit, so a badly written pattern such as (a+)+ cannot freeze the page. Your text never leaves the browser.

Illustration of a paper strip of small tiles under a magnifying glass that highlights a few tiles in amber, with an uneven comb beside it to suggest pattern matching

How to test a regular expression

  1. 1

    Type the pattern between the two slashes (do not type the slashes yourself), or pick a ready-made pattern to start from.

  2. 2

    Turn on the flags you need: g for all matches, i to ignore case, m so ^ and $ work per line, u for Unicode classes such as \p{L}.

  3. 3

    Paste the text to test. Matches are highlighted in alternating colours, the count appears on the right, and the Matches table shows positions and groups.

  4. 4

    To rewrite text, enable Replace and enter a replacement using $1, $2 or $<name>; the result updates live and Copy grabs it.

  5. 5

    Read “Pattern explained, piece by piece” to confirm the pattern means what you think before pasting it into your code.

Common regex syntax

SyntaxMeaningExample
.Any character except a newlinea.c matches abc, a-c
\d \w \sDigit, word character (A–Z, 0–9, _), whitespace\d\d matches 42
[abc] [^abc]One character in / not in the list[aeiou] matches a vowel
* + ?0 or more, 1 or more, optionalcolou?r matches color and colour
{n} {n,} {n,m}Exactly n, at least n, n to m times\d{4} matches 2026
^ $Start and end of text (or line with m)^Hello matches at the start
(…) (?<name>…) (?:…)Capture group, named group, non-capturing group(\d+)-(\d+) captures two groups
a|bEither a or bcat|dog
(?=…) (?!…)Must / must not be followed by\d+(?=px) matches numbers before px
\bWord boundary\bcat\b does not match inside concat

\w and \b only know ASCII letters. For accented or non-Latin text use [\p{L}\p{M}]+ with the u flag.

JavaScript regex flags

FlagEffectUse it when
gFind every match instead of stopping at the firstCounting, listing, replacing all
iIgnore upper / lower caseKeyword search regardless of case
m^ and $ match at line starts / endsMulti-line text, logs
sDot also matches newlinesCapturing a multi-line block
uUnicode mode: \p{…}, emoji, \u{…}Accented text, emoji
yMatch only at lastIndexWriting a tokenizer

Real-world examples

Spot invalid phone numbers in a list

Choose a phone pattern and paste the column from your spreadsheet: valid numbers light up, while numbers with missing digits stay plain, so the rows to fix stand out.

Turn dd/mm/yyyy into yyyy-mm-dd

Use (\d{2})/(\d{2})/(\d{4}) with g, enable Replace and enter $3-$2-$1: “05/11/2026” becomes “2026-11-05”, ready for a database import.

Pull order IDs out of emails

For IDs like ORD-2026-000123 use ORD-\d{4}-\d{6}. Wrap the digits in parentheses to get just the number as group $1.

Check an HTML form pattern

The pattern attribute of an HTML input uses JavaScript regex syntax (with ^ and $ added for you). Try the expression here with a few good and bad values before shipping it.

Common problems and fixes

Only one match shows up although there are several.
Turn on the g flag. Without it the regex stops at the first match (String.match and replace behave the same in code).
\w does not match accented letters.
\w is only A–Z, a–z, 0–9 and _. Use [\p{L}\p{M}] with the u flag instead.
The tester reports a timeout.
Nested quantifiers like (a+)+, (.*)* or (\w+\s?)* can try billions of combinations when there is no match (catastrophic backtracking). Be more specific: remove the nesting, replace .* with [^,]* or add anchors.
The dot matches everything.
A dot means “any character”. To match a literal dot write \. (for example example\.com).
The match is far too long.
* and + are greedy and take as much as possible. Add ? to make them lazy: <.+?> instead of <.+>.
Works here but not in my code.
Inside string literals in JavaScript, Java or C# the backslash must be doubled ("\\d+"). A /\d+/ literal in JavaScript stays as is. Python, PHP and Go differ in a few details (named groups, lookbehind).

Which regex engine does this use?

Patterns run on the browser's RegExp, which follows ECMAScript exactly as JavaScript and TypeScript do in the browser or Node.js. Most common syntax matches PCRE (PHP), Python and Java, with small differences: Python writes named groups as (?P<name>…) where JavaScript uses (?<name>…), and Go supports neither lookbehind nor backreferences.

The explanation comes from a small purpose-built tokenizer meant to make each symbol readable. It does not replace the engine: matches, syntax errors and replacements always come from the browser's RegExp itself.

Why there is a 1.5-second limit

Some patterns become exponentially slow when the text does not match. ^(a+)+$ against thirty a's followed by a b has to try over a billion ways to split the string. The same mistake is behind ReDoS outages at real web services.

The tester runs the pattern in a Web Worker and stops it after 1.5 seconds so you can fix it. If it times out here, it will probably be slow on your server too.

Limits of the ready-made patterns

The email, phone, ID card and licence-plate patterns check the shape of a value for quick filtering. They cannot confirm that the data really exists, and each one shows its limits under the picker.

  • Vietnamese mobile: 03, 05, 07, 08 or 09 prefix (or +84), 10 digits, no spaces inside.
  • Vietnamese ID card: 12 digits starting with 0; the first three are the birth-province code.
  • Email: good for everyday addresses, not every case RFC 5322 allows.

Glossary

Regex
A pattern used to search, validate or replace text.
Flag
An option that changes how matching works: g, i, m, s, u, y.
Capture group
A part in parentheses that is saved and reusable as $1, $2… or \1.
Quantifier
*, +, ?, {n,m}: how many times the previous item repeats.
Lookahead / lookbehind
A condition on what follows / precedes the match without including it.
Backtracking
Retrying other ways to match after a dead end; too much of it makes a regex extremely slow (ReDoS).

Frequently asked questions

Is this the same regex as PHP or Python?

Mostly. The tester uses JavaScript (ECMAScript) rules; a few things such as Python's (?P<name>) groups or PCRE's x flag differ. Results match JavaScript, TypeScript and Node.js exactly.

Is my text sent anywhere?

No. The pattern and text are processed in your browser (in a Web Worker) and never uploaded.

How do I match accented letters?

Use [\p{L}\p{M}]+ with the u flag. \w only knows unaccented A–Z.

Why does the table stop at 200 rows?

To keep the page fast with thousands of matches. Highlighting and replacement still cover everything (up to 5,000 matches).

What is the difference between $& and $1?

$& is the whole match, $1 is the first capture group. $<name> inserts a named group and $$ inserts a literal $.

My pattern timed out. What now?

Look for nested quantifiers or adjacent .* parts and make the pattern more specific: limit the characters, add ^ and $, remove nested repetition.

Ratings and comments

Loading…