# Regex Tester

URL: https://tools.otaku-dojo.com/en/regex-tester
Updated: 2026-10-03

The Regex Tester highlights every match in your test text as you type a regular expression and lists the values of capture groups ($1, $2) and named groups. Fill in "Replace with" to preview the result of a replace. It uses your browser's JavaScript regex engine and supports the g, i, m, s and u flags.

## How to use the Regex Tester

1. Type the pattern in "Regular expression" — no surrounding slashes needed.
2. Enter the text to test below, or press "Sample" to load an email example.
3. Toggle flags such as global (g), case-insensitive (i) and multiline (m).
4. The right side shows the match count, highlighted positions and each match's groups; add a replacement such as $1 to preview a replace.

## Specs & key facts

- **Engine**: JavaScript (ECMAScript) RegExp
- **Flags**: g global, i ignore case, m multiline, s dotAll, u Unicode
- **Shows**: Highlighted matches, groups, named groups, replace preview
- **Limits**: Counts up to 1,000 matches, lists the first 200
- **Processing**: In your browser (nothing is uploaded)
- **Price**: Free, no sign-up

## Examples: Extract US-style phone numbers

```regex
Pattern: \(?\d{3}\)?[ -]?\d{3}-\d{4}
Text: Call (555) 123-4567 or 555-987-6543
```

→

```regex
#1 (555) 123-4567
#2 555-987-6543
```

## Examples: Reorder a date with groups

```regex
Pattern: (\d{4})-(\d{2})-(\d{2})
Replace with: $2/$3/$1
Text: 2026-10-03
```

→

```regex
10/03/2026
```

## FAQ

### Will a regex tested here work in PHP or Python?

Most basic syntax is the same, but engines differ: PHP's PCRE supports recursion and possessive quantifiers, and Python writes named groups as (?P<name>...). This tool uses the JavaScript engine, so double-check before using it elsewhere.

### Why is only one match found?

Make sure the g (global) flag is on. Without it, a regex returns only the first match.

### Why don't ^ and $ match each line?

By default they match the start and end of the whole text. Turn on the m (multiline) flag to match each line.

### What does $1 in the replacement mean?

$1 and $2 insert the first and second capture groups, $& inserts the whole match, and $<name> inserts a named group.
