A regular expression describes a pattern that can be searched for in text. JavaScript uses regex for form validation, parsing, extraction, and transformations, but a pattern that compiles may still match the wrong cases. This tester lets you supply a pattern, flags, and a sample string, then reports what the JavaScript regular-expression engine finds. It is intended for experimentation and debugging, not as a proof that a production validator is secure or complete. Test realistic positive and negative examples before depending on a pattern in code.
Enter a pattern without surrounding slash delimiters in Pattern, set flags in the separate Flags field, paste a multiline or single-line sample into Test String, and click Test Regex. The default flag is `g`, meaning global matching. The tool validates the pattern and flags first, then displays total matches and elapsed milliseconds. Each visible result includes matched text, its zero-based index, and any captured groups. Clear restores blank fields and the default global flag, removing prior results and errors.
For an example, use the pattern `\d+`, flag `g`, and sample `order 31, then 42`. The tester reports two matches, `31` and `42`, with indices that identify where each begins. Add parentheses, such as `(\d+)`, to create a capture group and see the captured value in the group list. Remove `g` to inspect only the first match. These results demonstrate JavaScript behavior for that exact input; they do not prove that the matched numbers meet a business rule or that all intended examples are covered.
The flags field accepts JavaScript flags recognized by the current browser runtime, such as global, case-insensitive, multiline, dot-all, Unicode, sticky, or indices where supported. Duplicate or incompatible flags and malformed syntax are reported as validation errors. The tester lists at most 100 match rows in the result panel, even if a larger total was collected; the helper also stops its global scan after 10,000 iterations and advances past zero-length matches to avoid getting stuck. Elapsed time is descriptive, not a performance guarantee.
Use the tester while learning anchors, character classes, quantifiers, alternation, groups, and flags, or when debugging a log parser with a small representative sample. Regex Generator offers a catalog of common patterns, including email-like, URL, phone, and date examples, which you can copy here and then test. Slug Generator demonstrates normalization rather than regex matching; Credit Card Validator uses a Luhn calculation in addition to number formatting, illustrating why one regex is not the same as complete validation.
Pattern execution occurs through JavaScript's regular-expression engine in the browser and the component contains no remote matching request. However, pathological patterns can consume substantial CPU on large strings; use small, synthetic examples and avoid untrusted patterns in critical services without safeguards. This tool does not implement a timeout, and reported milliseconds cannot guarantee a production workload is safe. Sensitive sample text remains visible in the page, so redact private logs and credentials before testing or taking screenshots.
Treat matches as candidates that need application-specific validation. A simple email pattern, for example, cannot prove that a mailbox exists; a date-shaped string may still be an impossible calendar date; and a number-shaped card string does not mean a payment instrument is active. Test empty input, punctuation, Unicode, line breaks, boundaries, and near-miss cases. If an error appears, confirm that you entered the pattern without slash delimiters and used only supported flags, then add complexity incrementally.
Capture groups are returned as an ordered list for each match, so parentheses in the expression affect the result details. Use non-capturing groups such as `(?:...)` when grouping is needed only for precedence and should not become a reported value. A pattern with optional groups may show empty or undefined-like entries depending on match behavior. Check group positions against a small sample before integrating them into a parser, because changing one pair of parentheses can shift the meaning of every later capture.
Flags alter important parts of matching. Case-insensitive mode changes letter comparison, multiline mode changes how line anchors behave, and dot-all mode changes whether a dot can match line breaks. Global mode collects multiple results but does not mean every line is independently evaluated. Try one flag at a time with a sample containing upper and lowercase text and multiple lines. Use the same JavaScript runtime as your application when a pattern depends on newer syntax, because browser support can differ across versions.
The execution-time display measures the local call around the regex helper and is useful only as a rough comparison for the current browser and sample. It does not account for different server hardware, production concurrency, or adversarial inputs. A regular expression that is fast on a short example may behave very differently on a long string. If a pattern will process untrusted requests, review its complexity and consider bounded input, a parser, or safer matching strategies rather than trusting one successful interactive test.
Match indices are zero-based offsets into the JavaScript string, not human-oriented character numbers. For text containing emoji or some other surrogate-pair characters before a match, a displayed index can differ from what a reader counts as one visible symbol per position. Use the same indexing conventions in downstream code, and test Unicode cases explicitly if your feature reports or slices positions. Captures contain text only; the display does not provide named-group metadata or replacement output.