Regex Tester

Inputs

Letters after the closing slash, like g or gi.

Results

Matches
—
#PositionMatchGroups

Regular expressions are compact search patterns, handy for validating input, pulling data out of text and search-and-replace. This tester runs your pattern with the browser’s JavaScript engine and shows each match in place, along with its position and capture groups, so you can fix a pattern before it goes into code.

How to use it

  1. Type the pattern without the surrounding slashes.
  2. Set flags: g finds every match instead of only the first, i ignores case, m makes ^ and $ match at each line.
  3. Paste test text; matches are highlighted and listed with their capture groups.

Example: the pattern (\w+)@(\w+)\.com with flag g on “Write to ann@example.com or bob@test.com, not carol@example.org.” finds 2 matches: ann@example.com (groups ann, example) and bob@test.com (groups bob, test). The .org address doesn’t match.

Questions and answers

Which regex flavor is this?

JavaScript (ECMAScript), as run by your browser. Most syntax is shared with PCRE, Python and Java, but some features differ, such as possessive quantifiers and inline flags, which JavaScript doesn’t have.

Why does it find only one match?

Without the g flag, JavaScript stops at the first match. Turn on g to find them all.

How do I name a capture group?

Write (?<name>...), for example (?<year>\d{4}). The table then shows each group by name.

Why was my pattern stopped?

Some patterns, such as (a+)+$, try an enormous number of ways to match before failing. The tester stops them after a moment so the page stays responsive; in real code they can freeze a program.

Link with pre-filled values

Add # and these parameters to the end of this page's address to open the tool with values already filled in.

ParameterWhat it sets
patternThe regular expression, without slashes, URL-encoded.
flagsFlags: any of d, g, i, m, s, u, v, y.
textThe text to search, URL-encoded.

Example: https://toolabelle.com/regex-tester/#pattern=%5Cd%7B3%7D-%5Cd%7B4%7D&flags=g&text=Call+555-1234+or+555-9876.

Related tools