# Regex tester (JavaScript)

Test a JavaScript regular expression against your text in the browser's own engine. Matches are highlighted and listed with their groups and positions; write flags as /…/gi. Nothing is uploaded.

Page: https://toolkitnow.org/tools/regex-tester/

Type a pattern, as /…/flags or bare, and the text to search. It runs in this browser's JavaScript engine. The gray text is an example.

## Good to know

### Which engine

Your browser's JavaScript engine, the same that runs `text.match(/…/)` in a web page or Node.js. Patterns written for PCRE (PHP), Python or .NET can behave differently: JavaScript has no possessive quantifiers, no `\A` or `\Z`, and a `$` with the `m` flag also matches before a `\r`.

### Flags

Write them after the pattern: `/cat/gi`. A pattern typed without slashes is searched for every match (`g`). Without `g` only the first match is shown, as `exec` finds it.

### Positions

Counted as JavaScript counts string positions, in UTF-16 units: a character such as 😀 counts as 2. Without the `u` flag a match can start inside such a character; with `u` (or `v`) it cannot. An empty match shows as a thin mark.

### Slow patterns

A pattern that backtracks without end, such as `(a+)+$` on a long run of a's followed by another letter, is stopped after 0.3 seconds instead of freezing the page.

### Open from a link

`?pattern=/\d+/g&input=a1b22` opens the page with that pattern and text. A `+` stays a `+`; write a space as `%20`, `&` as `%26` and `#` as `%23`.

Runs in the browser; nothing is uploaded. Part of toolkitnow.org.
