UTILITIES NEWBIE

Regular expression tester

Test a browser JavaScript pattern against text, or generate a pattern without running a match. Inspect the JSON result and use representative matching and nonmatching examples.

Input

0 UTF-16 code units

Inputs start empty. Load example fills them only when you choose it. Reset clears current inputs and results.

Output

This tool processes inputs in your browser. See the Privacy Policy for details about hosting and performance measurement.

Separate match and captures. Full explanation follows.
AB-12 at index 0. Text explanation

The checked global pattern captures uppercase labels and digits from AB-12 CD-7. Full matches begin at zero and six UTF-16 code units, with separate captured strings. This finite observation is not whole-input semantic validation.

Turn a pattern idea into a small set of observed matches

Choose testing, literal escaping or a preset deliberately

Regex Tester applies a JavaScript regular expression to text and reports observed matches, indexes and capture groups. The same page can escape a literal string or generate one of its supported simple patterns. Choose the operation before interpreting the result. A generated pattern is text to test, not a security validator, and an escaped literal is not a search that has already run. Use a short synthetic input that contains both an expected match and a near miss so the operation’s purpose is visible.

Enter the pattern without surrounding slash delimiters and put flags in the separate field. The supported flags are g, i, m, s, u and y, with no duplicate flag. They belong to JavaScript’s regular-expression model; a pattern from another regex dialect may mean something different or be rejected. In particular, a familiar example copied from documentation for another engine is not evidence that this page supports its syntax. Keep the exact pattern, flags and source together when asking someone to reproduce an observation.

The test result records what happened for the submitted specimen. It does not prove that every future input will be accepted or rejected correctly. A pattern that extracts a demonstration label is not automatically suitable for validating a password, an email address or a transaction. Define the intended input contract separately and include meaningful counterexamples. Private records are usually unnecessary for developing a small pattern; replace them with synthetic text that preserves the relevant punctuation, length and character types without exposing unrelated personal information.

Trace the two labelled matches and their captures

Checked synthetic input

action: Test pattern
pattern: ([A-Z]+)-(\d+)
flags: g
source: AB-12 CD-7

Recorded processor observation

{
  "matches": [
    {
      "match": "AB-12",
      "index": 0,
      "groups": [
        "AB",
        "12"
      ],
      "namedGroups": null
    },
    {
      "match": "CD-7",
      "index": 6,
      "groups": [
        "CD",
        "7"
      ],
      "namedGroups": null
    }
  ],
  "truncated": false
}

The checked example searches AB-hyphen-twelve followed by CD-hyphen-seven, using a pattern with one uppercase-letter group and one digit group. The global flag requests repeated matching. The first full match is AB-hyphen-twelve at index zero; its captures are AB and twelve. The second is CD-hyphen-seven at index six, with captures CD and seven. The exact block preserves the actual punctuation and JSON result. The illustration explains how the full match and its captures differ rather than presenting captures as independent searches.

An index is a position in the original text, measured in JavaScript UTF-sixteen code units. It is not a line number, a byte offset or always a count of visible characters. A supplementary Unicode character can occupy two code units. Keep the original source when highlighting a reported match in another system, because normalizing line endings or changing text before applying the index creates a different position mapping. The displayed result is tied to this exact specimen and should not be detached from it during a handoff.

Without global or sticky behavior, the implementation stops after its first match. With repeated matching, the result is still bounded rather than an unlimited extraction service. Capturing parentheses create numbered groups, while named captures are returned in their own object when present. A no-match result is an empty matches list, not necessarily a syntax failure. Compare the result structure with the question being asked before changing a pattern; a valid expression that finds nothing is different from a malformed expression that cannot be constructed.

Read the limits and Unicode behavior before extending a pattern

Pattern and flag inputs are each limited to one thousand UTF-sixteen code units, and source text is bounded to one hundred thousand characters. The result stops at one thousand matches and marks the listing as truncated at that threshold. Output is also bounded to one million characters, with accumulated capture and serialized-result size checked. Hitting a cap is not proof that the source contains exactly that many possible matches. Keep the truncation indication with the exported observation instead of reporting the bounded list as a complete inventory.

Zero-length matches require a special progress rule so a repeated search does not remain at the same position forever. With Unicode mode, the implementation advances past a supplementary code point by two code units; otherwise it advances one. The checked empty-pattern example over an emoji reports the expected boundary indexes under Unicode mode. This behavior does not turn all regex indexing into user-perceived grapheme indexing. Combining marks and text segmentation have separate concerns, so use a tool designed for that task when the requirement is counting visible characters.

Supported syntax can still be expensive on a particular input. The page’s local worker workflow has processing and startup bounds, but those controls are not a proof that every pattern is efficient. Develop with small representative cases and avoid treating this editor as an unbounded stress-test service. A timeout and an invalid-pattern message are different observations. Preserve the pattern and specimen when diagnosing either one rather than repeatedly retrying a difficult expression without changing or understanding the conditions that caused the problem.

Build a reviewable set of positive and negative cases

For log extraction, identify exactly which part of a synthetic line is the label and which part is the value, then add a line that should not match. Inspect full matches and captures separately. A pattern can find the desired substring while also matching text you did not intend to accept. If the task is whole-string validation, include boundaries appropriate to the actual input contract and test additional text before and after the specimen. This page cannot decide that contract merely from the fact that one match was returned.

For literal search, Escape literal converts regex metacharacters in the supplied text into their escaped form. The checked literal a-plus-b-dot-parenthesized-x becomes a pattern that can describe those punctuation characters literally. It has not been tested against another source merely by being generated. Likewise, the simple date preset checks a shape rather than proving a calendar date exists. Use separate semantic validation when the requirement involves real dates or another domain-specific meaning. A convenient preset should not be promoted into a broader guarantee than its actual expression supports.

Copy and Download preserve the current output text, including match metadata where present. They do not apply the pattern to a server, change source files or validate a downstream application. Keep the pattern, flags, source and bounded result as one reproducible record. Reset clears the current workspace, and changing an input invalidates the previous result. The accessible illustration supports inspection of the example, while broader correctness, performance and security decisions remain tied to the receiving system and its own representative tests.

Supporting reference: JavaScript match/capture context; local caps and supported flags described above.

Find a tool

Type a tool name, such as JSON or percentage.

Quick links

Browse by category

All tools