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
Enter the example
- Open regex101.
- Select JavaScript in the flavor selector.
- Select Match mode.
- Enter this pattern in Regular Expression:
\bORD-(?<id>[0-9]{4})\b
- Enable the
gflag to find every match. - Paste this text into Test String:
ORD-0042 pending
ORD-0187 sent
ORD-42 invalid
XORD-0001 invalid
Read the result
The input contains two matches. The named capture group id contains each match's four digits.
| Full match | Group id |
|---|---|
ORD-0042 | 0042 |
ORD-0187 | 0187 |
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.
Change one part
- Change
{4}to{2,4}. - Verify that
ORD-42now matches. - 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.