Test regex

Run a JavaScript regular expression against sample text and inspect matches.

freeworks offlinenothing uploaded
ToolRegex Tester
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The expression is compiled with selected flags and applied to input, returning match spans, captures, and global results. Syntax errors are reported before matching.

  • JavaScript behavior matches browser and Node applications.
  • Explicit flags expose global state.

Worked example

Test email extraction pattern with match positions
Use a regex pattern to find email addresses in text
Input
											Contact us at [email protected] or [email protected] for help.
										
Output
												Pattern: /\w+/g
Matches: 12

Match 1: "Contact" (position 0-7)
Match 2: "us" (position 8-10)
Match 3: "at" (position 11-13)
Match 4: "support" (position 14-21)
Match 5: "example" (position 22-29)
Match 6: "com" (position 30-33)
Match 7: "or" (position 34-36)
Match 8: "sales" (position 37-42)
Match 9: "company" (position 43-50)
Match 10: "org" (position 51-54)
Match 11: "for" (position 55-58)
Match 12: "help" (position 59-63)

Input:   Contact us at [email protected] or [email protected] for help.
         ^^^^^^^ ^^ ^^ ^^^^^^^ ^^^^^^^ ^^^ ^^ ^^^^^ ^^^^^^^ ^^^ ^^^ ^^^^
											

When to use this

Frontend validation, log debugging, and unit-test design test expressions.

Edge cases

  • An invalid escape prevents compilation.
  • Global mode advances lastIndex between tests.
  • Without anchors a pattern can match only a substring.

References