# Regex lab

> Test JavaScript regular expressions against your own text. See every match and capture group, with a plain-English note on each flag.

Source: https://ebrahimsameh.com/tools/regex-lab/

Regex lab is a scratchpad for JavaScript regular expressions. Type a pattern and some test text, and it highlights every match and lists its capture groups as you type.

## How it works

The pattern runs in your browser on the same JavaScript regex engine your code uses, inside a Web Worker. If a pattern runs longer than a second, the worker is stopped so a runaway pattern can't freeze the page. Results list up to 1,000 matches with their positions, numbered groups and named groups.

## Questions

### Which regex flavour does it use?

JavaScript (ECMAScript), as your browser implements it. Features from other engines, such as possessive quantifiers in PCRE, won't work here.

### Which flags can I use?

d, g, i, m, s, u, v and y. The lab always looks for every match, so g is on even if you leave it out.

### Why did my pattern time out?

Usually catastrophic backtracking. Nested quantifiers like (a+)+ can take exponential time on some inputs. Remove the nesting or make the inner part more specific.
