FLXCode Regex Tester

FLXCode apps

Appearance

Regex Tester

Type a pattern and some text. Matches, groups and the replacement show as you type.

Flags

Runs in your browser, in a background worker. Nothing is saved, shared or sent. Text up to 1 MB.

Result

Type a pattern and some text.

No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.

Problem or idea? Email us

Quick start

  1. Type a pattern, without the slashes. Example: (\d+)-(\d+)
  2. Tick the flags you need. g finds every match, not only the first.
  3. Paste or type your text. Matches are highlighted and listed with their position and groups.
  4. Switch on Preview a replacement to try $2-$1.

This tester uses the JavaScript engine of your browser. A pattern that works here works in JavaScript code, Node.js included. Other languages can differ.

JavaScript regex cheat sheet

Common regular expression syntax
SyntaxMeaning
.Any character except a line break (with flag s, also line breaks)
\d \w \sA digit, a word character (letter, digit, underscore), a whitespace character
\D \W \SThe opposite of the three above
[abc] [^abc] [a-z]One of a, b, c. Anything but those. A range
^ $Start and end of the text (of each line with flag m)
\b \BA word boundary, and not a word boundary
* + ?Zero or more, one or more, zero or one
{3} {2,5} {2,}Exactly 3, between 2 and 5, at least 2
*? +? ??The lazy versions: as few as possible
(abc)A capture group, numbered from 1
(?<name>abc)A named group, read back with \k<name> or $<name>
(?:abc)A group that does not capture
a|ba or b
(?=abc) (?!abc)Lookahead: followed by, not followed by
(?<=abc) (?<!abc)Lookbehind: preceded by, not preceded by
\1 \k<name>The same text as an earlier group
\p{L} \p{Lu}A letter, an upper case letter (needs flag u or v)
\. \( \\A literal dot, bracket or backslash

In a replacement

Replacement patterns
SyntaxMeaning
$1 $2The text of group 1, 2, and so on
$<name>The text of a named group
$&The whole match
$$A dollar sign

Flags

  • g global: all matches. i ignore case. m multiline: ^ and $ work per line. s dot all.
  • u unicode and v unicode sets: work on whole characters. Use one, not both.
  • y sticky: a match must start exactly where the last one ended. d indices: the page uses it to show where each group sits.

Slow patterns

A pattern with nested repeats, like (a+)+$, can take longer and longer as the text grows. This is called catastrophic backtracking. The page runs your pattern in a background worker and stops it after 1.5 seconds, so the page stays usable and you see a message.

Limits

  • JavaScript flavour only, no PCRE or Python mode.
  • Text up to 1 MB. Up to 10,000 matches counted, the first 1,000 listed.
  • No pattern explainer. The cheat sheet above is the help.

How it works and privacy

Your pattern, text and replacement are used in your browser only. They are not put in the address, stored or sent. We count events without cookies, like "pattern run" (details). Your pattern is never part of them.

FAQ

Which regex flavour is this?

JavaScript, the one built into your browser. PCRE, Python, Java and .NET differ in small ways: possessive quantifiers and atomic groups do not exist in JavaScript, and named groups are written (?<name>...) rather than (?P<name>...).

Why does . not match a line break?

By default the dot skips line breaks. Switch on the s flag (dot all) and it matches them too.

Why does my pattern only find one match?

Without the g flag a pattern stops at the first match. Switch on g to find them all.

Does lookbehind work?

In current versions of Chrome, Edge, Firefox and Safari, yes. Very old browsers do not have it, and the page tells you when a pattern is not accepted.

What do the u and v flags do?

Both make the pattern work on whole Unicode characters instead of 16-bit pieces, so emoji count as one character and \p{L} works. The v flag adds set operations inside classes. You can use one or the other, not both. If your browser lacks v, the page greys it out.

Why does the page say my pattern is too slow?

Some patterns, like (a+)+$ on a long run of a followed by b, take exponentially longer with each extra character. The page stops a run after 1.5 seconds so it stays usable. Rewrite the pattern so the same text cannot be matched in many ways.

Is my pattern or text sent anywhere?

No. They are handled in your browser, in a background worker. They are not saved, put in the address or counted in our events.

How many matches and how much text can it handle?

Text up to 1 MB, and up to 10,000 matches counted. The page lists the first 1,000.

More from FLXCode

Share Regex Tester