Regex Tester
Runs in your browserTest JavaScript regular expressions and inspect matches, capture groups, and replacements.
Matches and capture groups
How to use
Steps
- Enter a JavaScript regex pattern without surrounding slashes. Put flags such as
g,i,min the Flags field. - Paste the content into Test text. To preview a replacement, enter a template under Replace with. You can use
$1,$<name>or$&. - Select Test regex. Inspect highlights and positions under Matches and capture groups. Check the replacement preview and select Copy replacement result if needed.
Example
Test book-012 card-037 with the pattern below, set flags to g, use a replacement of $<name>_$2, and expect book_012 card_037.
(?<name>[a-z]+)-(\d{3})
Tips
gmatches all occurrences,iignores case, andmmakes anchors match the start and end of each line. An empty replacement deletes the matches.- Match offsets are zero-based UTF-16 positions. Test text is limited to 50,000 characters. If there are more than 500 matches or the search times out, narrow the input or simplify the pattern.