# Regex Tester

> Online regex tester: try a regular expression on your text, see highlighted matches, capture groups and positions, and preview replacements with $1. Free, runs in your browser.

Source: https://widgetpantry.com/en/regex-tester · Türkçe: https://widgetpantry.com/tr/regex-test

Write a regular expression and paste your text: matches are highlighted in place, and every match is listed with its position and capture groups. It uses JavaScript's own regex engine, and your text never leaves your browser.

Runs in your browser: files and text are not uploaded. [Use the tool](https://widgetpantry.com/en/regex-tester)

## How to use it

1. Write the regular expression and pick the flags you need (g, i, m, s, u).
2. Paste the text to test; matches are highlighted as you type.
3. Optionally enter a replacement ($1, $'<name>') and copy the result.

## How to test a regular expression

A regular expression (regex) describes a pattern to find in text: \d is a digit, \w a letter, digit or underscore, \s whitespace, and . any character; + means one or more, * zero or more, ? optional, and '{2,4}' between two and four repeats. Parentheses () capture a group, and (?'<name>'…) gives it a name.

Flags change how the search runs: g finds every match (otherwise only the first), i ignores case, m makes ^ and $ match at each line, s lets the dot match line breaks, and u turns on Unicode mode (recommended for accented letters and emoji).

The tool runs your browser's JavaScript engine, so an expression that works here behaves the same in JavaScript and TypeScript code. PHP, Python and Java use very similar syntax but differ in some details.

## From the blog

- [Regex Cheat Sheet: Syntax, Flags and Ready-to-Use Patterns](https://widgetpantry.com/en/regex-cheat-sheet): Regular expression basics in one page: character classes, quantifiers, groups and flags, plus tested patterns for email, URL, date, time, IPv4, hex colours, passwords and common find-and-replace jobs.

## Frequently asked questions

### Which regex flavour is this?

Your browser's JavaScript (ECMAScript) engine. Named groups, lookbehind and Unicode properties (\p{L}) are supported. Most expressions work the same in Python and PHP, but small differences exist.

### What can I use in the replacement?

$1 and $2 insert numbered groups, $'<name>' a named group, $& the whole match and $$ a dollar sign. Without the g flag only the first match is replaced.

### Why did the page slow down?

Nested repeats such as (a+)+ can take an extremely long time on some text (catastrophic backtracking). Simplify the expression; if the tab freezes, reload the page.

### Is my text sent anywhere?

No. The expression and text are processed only in your browser; nothing is uploaded or stored.

## Related tools

- [Text Cleaner](https://widgetpantry.com/en/text-cleaner): Text cleaner: remove extra spaces, empty lines, line breaks and duplicate lines. Fix text copied from a PDF in one click. Free, runs in your browser.
- [JSON Formatter](https://widgetpantry.com/en/json-formatter): Online JSON formatter and validator: pretty-print, validate and minify JSON. Line and column for errors, 2/4-space or tab indentation, one-click copy.
- [URL Encoder/Decoder](https://widgetpantry.com/en/url-encode-decode): URL-encode text or decode codes like %C3%A7: a single part or a full address, with an option for + as space. Runs in your browser; nothing is sent.
