Skip to main content

Test your first regex

regex101 runs regex matching locally in your browser. Your test text is not uploaded for matching.

A regular expression describes text you want to find. This example finds two order identifiers and captures their four digits.

Free
Included
Pro
Included
Self-hosted
Included
Compare plans

Enter the example​

  1. Open regex101.
  2. Select JavaScript in the flavor selector.
  3. Select Match mode.
  4. Enter this pattern in Regular Expression:
\bORD-(?<id>[0-9]{4})\b
  1. Enable the g flag to find every match.
  2. Paste this text into Test String:
ORD-0042 pending
ORD-0187 sent
ORD-42 invalid
XORD-0001 invalid

Open in regex101

Read the result​

The input contains two matches. The named capture group id contains each match's four digits.

Full matchGroup id
ORD-00420042
ORD-01870187

The third line has only two digits. The fourth line lacks the word boundary before ORD.

The Explanation panel describes the pattern. The match details connect each highlighted match to its capture groups. The flavor selector determines the regex syntax and engine.

1. Pattern and flags. 2. Test input. 3. Engine selector. 4. Pattern explanation. 5. Matched text and captured groups.
Two matching order identifiers and their named id captures in the JavaScript editor.

Change one part​

  1. Change {4} to {2,4}.
  2. Verify that ORD-42 now matches.
  3. Restore {4} to require four digits.

If your application gives a different result, compare its engine, flags, and input representation.

Read about privacy and local processing, including saved workspaces and integrations.