Regex Testing Basics for JavaScript Patterns
Learn how to test regular expressions, use flags and avoid common pattern surprises.
Related tool
Open tool
Regex Tester helps you apply this guide directly in the browser.
Start with real sample text
A regex is easier to debug when the sample text includes examples that should match and examples that should not match.
Testing only the successful case can hide mistakes that appear later in production.
Flags change behavior
The g flag finds multiple matches. The i flag ignores case. The m flag changes how line anchors behave.
When a pattern works in one environment but not another, flags are one of the first things to check.