---
title: "Regex Tester — Test & Debug Regular Expressions | fbuff"
description: "Test regular expressions in real time, see every match and capture group highlighted, and copy code for JavaScript, TypeScript, Python or PHP. Free and private."
url: https://fbuff.com/tools/regex-tester/
---

Developer

# Regex Tester & Extractor

Test regex patterns in real time, highlight matches, inspect capture groups, and generate code snippets.

Regex Workspace

Matches: 2

REGEX PATTERN

FLAGS

SAMPLE TEXT

HIGHLIGHT RESULT

```
product-120
order-42
invalid
```

CAPTURE GROUPS

| # | Full Match | Groups |
| --- | --- | --- |
| 1 | product-120 | g1: product \| g2: 120 |
| 2 | order-42 | g1: order \| g2: 42 |

Reference

### Regex Cheat Sheet

| Token | Meaning |
| --- | --- |
| . | Any character except newline |
| \d | Digit (0-9) |
| \w | Word character |
| \s | Whitespace |
| ^ / $ | Start / end of line |
| [abc] | Any character in class |
| [^abc] | Any character not in class |
| ( ... ) | Capture group |
| (?: ... ) | Non-capturing group |
| a\|b | Alternation |
| * + ? | Quantifiers |
| {n,m} | Range quantifier |

### Code Snippet

LANGUAGE

```
const regex = new RegExp('(\\w+)-(\\d+)', 'g');
const text = 'product-120
order-42
invalid';
const matches = [...text.matchAll(regex.global ? regex : new RegExp(regex.source, regex.flags + 'g'))];
console.log(matches);
```

![A text card with a few highlighted segments under a magnifying glass, with an asterisk and bracket symbols beside it](https://fbuff.com/content/regex-tester.webp)

## How to use

1. Type your pattern in REGEX PATTERN, for example (\w+)-(\d+), and set the FLAGS such as g, i or m.
2. Paste the text to search into SAMPLE TEXT. Every match is highlighted in HIGHLIGHT RESULT as you type, and the match count updates.
3. Open CAPTURE GROUPS to see the full match and each group, which is what you would read in code.
4. Pick a LANGUAGE and click COPY SNIPPET to get ready-to-run code in JavaScript, TypeScript, Python, PHP, C# or Go.

## Test a regular expression in real time

A regex tester shows exactly what a pattern matches before you put it in code, which saves the guess-run-fix loop. Matches update as you type, a syntax error is reported right away, and the capture groups show what each pair of parentheses picked up.

The tester uses the JavaScript regular expression engine built into your browser, the same one Node.js and front-end code use. Most everyday patterns work the same in Python, PHP, C# and Go, but some features differ between engines, so run the generated snippet in your language once.

## Flags

Flags change how the whole pattern behaves:

| Flag | Name | Effect |
| --- | --- | --- |
| g | global | Find all matches, not only the first |
| i | ignore case | Treat upper and lower case as the same |
| m | multiline | Make ^ and $ match at the start and end of each line |
| s | dotAll | Let . also match line breaks |
| u | unicode | Treat the pattern and text as Unicode code points |
| y | sticky | Match only at the current position |
| d | indices | Record where each capture group starts and ends |

## Patterns people look up most

Some starting points you can paste and adapt: digits only ^\d+$; a simple email check [^\s@]+@[^\s@]+\.[^\s@]+; a US ZIP code ^\d{5}(-\d{4})?$; a date like 2026-10-24 (\d{4})-(\d{2})-(\d{2}); and repeated spaces \s{2,}. Test each against both text that should match and text that should not.

Be careful with patterns that nest repetition, such as (a+)+, on long input: they can take a very long time in many engines. Prefer specific character classes over .* when you can, and add ^ and $ when the whole string must match.

## Frequently asked questions

### Which regex flavor does this tester use?

JavaScript (ECMAScript), as built into your browser. Patterns that use features specific to PCRE, Python or .NET may need small changes; the code snippet helps you check in your language.

### Why does my pattern only find one match?

Without the g (global) flag, a JavaScript regex stops after the first match. The tester lists all matches, but add g in your code if you want every one.

### How do I match a literal dot or bracket?

Escape it with a backslash: \. matches a dot, \( a parenthesis and \[ a bracket. Without the backslash, these characters have a special meaning.

### Is my text uploaded?

No. Matching runs in your browser, so you can safely test patterns on logs or data you cannot share.

Found a problem or have an idea? [Report a problem](https://fbuff.com/contact/?tool=regex-tester)

Share

## You might also like

- - [JSON Path Finder Inspect JSON, copy exact JSONPath expressions, and test paths locally.](https://fbuff.com/tools/json-path-finder/)
- - [URL Encoder Decoder Encode and decode URL components locally in your browser.](https://fbuff.com/tools/url-encoder-decoder/)
- - [Base64 Encoder Decoder Encode and decode Base64 text locally in your browser.](https://fbuff.com/tools/base64-encoder-decoder/)
- - [GUID / UUID Generator Generate UUIDs and convert GUIDs to short GUIDs locally in your browser.](https://fbuff.com/tools/guid-uuid-generator/)
- - [JSON Formatter Format, prettify and validate JSON instantly. Minify in one click.](https://fbuff.com/tools/json-formatter/)
- - [Cron Job Parser Parse full crontab lines with commands, explain the schedule, and preview the next 5 runs.](https://fbuff.com/tools/cron-parser/)
- - [HTML Previewer Write or paste HTML and preview it live in a sandboxed iframe. Supports full pages and fragments.](https://fbuff.com/tools/html-previewer/)
- - [JWT Decoder Decode and inspect JWT tokens. View header, payload claims and expiry status instantly.](https://fbuff.com/tools/jwt-decoder/)
- - [Number Base Converter Instantly convert numbers between binary, octal, decimal, and hexadecimal. Supports large numbers. 100% client-side.](https://fbuff.com/tools/number-base/)
- - [Unix Timestamp Converter Convert Unix epoch to datetime and back. 100% client-side.](https://fbuff.com/tools/unix-timestamp/)
