Small tasks. A little easier.126 tools · No account required

Find your next tool

Search all 126 tools and their practical guides.

Developer

Test JavaScript regex captures with a bounded example

Enter a delimiter-free JavaScript pattern, inspect capture groups and indexes, and understand the worker timeout and match cap.

ERITHRA editorial3 min read

Separate the pattern from its flags

The Regex Tester runs JavaScript regular expressions. Enter the pattern without surrounding slash delimiters, place flags in their own field, and put the sample data in Test text. This matters when copying an expression such as /cat/gi from source code: enter cat as the pattern and gi as the flags.

The accepted flag letters are d, g, i, m, s, u, v, and y, with no duplicates. Actual expression support depends on your browser’s JavaScript engine. A listed flag can still fail if the browser does not support it or if it is combined with an incompatible flag.

Inspect values and positions together

Enter item-(\d+) as Pattern, g as Flags, and this test text:

item-42 item-7

The expected result contains two match objects. The first has index 0, text item-42, and a groups array containing "42". The second has index 8, text item-7, and a groups array containing "7". The match index follows JavaScript string indexing, so do not assume it is a user-perceived character count in text containing emoji or combining marks.

Remove the g flag and run again. The result now contains only the first match. This is a useful check when an expression looks correct but application code returns fewer results than expected. The y flag uses sticky matching and has different search behavior from a normal global scan.

Keep test cases representative

Try a valid value, an invalid value, and a near miss. For this pattern, item-abc should not match the numeric suffix. Also consider whether an expression should match inside a larger word; add boundaries or anchors only when that reflects the intended input rules.

The tool isolates matching in a worker and terminates it after a one-second safety limit. It accepts patterns up to 500 characters and test text up to 100,000 characters, returning at most 2,000 matches. A timeout indicates that this test exceeded the limit; it is not a proof that the pattern is safe or unsafe in every production environment.

Use results without exposing source records

Matching stays in the browser. Replace customer identifiers and confidential log lines with representative samples before sharing output. Downloaded results are JSON and can be inspected with JSON Formatter. For straightforward literal replacement, Find and Replace Text avoids the extra interpretation that regular expressions introduce.

regexJavaScriptdebugging

Put it into practice

Keep reading