forgehub. A small, independent toolbox

Regex Tester

How to test a JavaScript pattern in Regex Tester

Enter a JavaScript pattern without slash delimiters, paste test text and choose flags. Regex Tester updates after a short pause, or you can select Run / retry. Inspect the highlights and zero-based offsets, then check the status for completion, errors or partial results. Load sample gives you a starting example; working data lasts only in the current tab.

Open Regex Tester

Begin with a pattern and a small sample

Choose Load sample for a working starting point. It fills Expression with [A-Z]{2}-\d{3}, supplies a short signal log and enables only g, the Global flag. The pattern looks for two uppercase letters, a hyphen and three digits. In that log, AB-104, CD-208 and EF-412 fit; the lowercase ab-309 does not fit with the initial flags.

For your own check, enter the pattern alone in Expression, without surrounding slashes or flags appended to it. Paste the text to examine into Test text. Edits trigger evaluation after a 220 ms pause. Select Run / retry, or press Ctrl or Command plus Enter while editing either field, to run immediately. Keep an example that should match and one that should fail in the same test text.

Change one flag and inspect the difference

Leave g enabled to find all non-overlapping matches, subject to the display limit. Switch it off when you need only the first match. In the supplied sample, enabling i, Ignore case, also allows ab-309 to match. Changing a flag schedules another evaluation, so inspect the updated status before comparing counts.

The other controls address different behavior: m makes ^ and $ apply to each line, s lets a dot match line breaks, and u enables Unicode-aware matching. For example, ^AB-104$ checks an entire line with m enabled, whereas the unanchored AB-104 can match inside a longer line. Choose flags through the controls rather than adding them to Expression. Unsupported flag controls are disabled in the current browser.

Read highlights together with the offset list

Teal highlights show matched text in a separate, read-only result area. The Matches list gives each start and end position. Positions begin at zero and the end is exclusive: AB-104 by itself matches from 0 to 6, covering positions 0 through 5. These numbers count UTF-16 code units, so some emoji occupy two units.

An orange tick marks a zero-width match, whose start and end positions are equal. An expression such as ^ can match a position without consuming visible text. A tick therefore represents a match even when no letters are highlighted. The list reports whole-match offsets; capture-group inspection and replacement previews are outside the tool?s scope.

Distinguish a completed search from a stopped run

Read the status before treating an empty list as evidence that your pattern found nothing. Invalid syntax produces an Invalid expression message; correct the pattern and evaluate again. Editing clears old results and cancels running work, so a previous successful result is not retained as the answer to changed inputs.

Each evaluation runs in a disposable worker with a roughly 500 ms watchdog. A timeout means the result is incomplete. Shorten the text or simplify the pattern, then select Run / retry. Timing includes scheduling and worker startup, so it is not a regex benchmark. If the worker cannot start, evaluation is unavailable; the app suggests checking browser support and reloading.

Check limits and preserve your work deliberately

The input limits are 2,000 pattern and 100,000 test-text UTF-16 code units. Oversized input is rejected rather than silently shortened. At most 1,000 matches are displayed. If more exist, the status explicitly says the highlights are partial; exactly 1,000 matches does not by itself trigger that notice. Narrow the pattern or use a smaller sample when you need a manageable inspection.

The app uses your browser?s JavaScript RegExp engine, not PCRE, and browser syntax support can vary. Patterns, text and results stay in tab memory, with no saved history, uploads or export controls. Preserve any pattern you need in your own working document before leaving. Clear empties both inputs, restores g as the only selected flag and focuses Expression; refreshing also discards the session.

AI-assisted ForgeHub editorial. App capabilities were checked against its implementation; this guide is not an independent review.

Frequently asked questions

Why does the sample skip ab-309?

Load sample enables g but leaves i off. Its [A-Z] range matches uppercase letters. Enable Ignore case to include the lowercase ab-309 entry.

Can I paste /\d+/g into Expression?

Enter \d+ without the surrounding slash delimiters and select g using the Global control. The app passes the Expression field as the pattern to JavaScript RegExp.

Can I inspect capture groups or preview a replacement?

No. This version highlights whole matches and lists their offsets. Capture-group inspection and replacement previews are not included.

Does a timeout mean there were no matches?

No. The run stopped before completion. Simplify the expression or shorten the test text and select Run / retry. Use a completed evaluation to judge whether matches were found.