Enter a pattern and choose flags
The pattern describes a match. The test string supplies the text. Flags change how the selected engine interprets the pattern.
- Free
- Included
- Pro
- Included
- Self-hosted
- Included
Configure a match
- Select the engine used by your application.
- Select Match mode.
- Enter the pattern between the delimiter controls.
- Paste the actual text into Test String.
- Select the flags required for your task.
For JavaScript, this pattern finds four-digit order identifiers:
\bORD-(?<id>[0-9]{4})\b
With g, both ORD-0042 and ORD-0187 match. Without g, JavaScript stops after the first match.
Flags
The flag menu depends on the engine. These JavaScript flags illustrate different jobs:
| Flag | Effect |
|---|---|
g | Find successive matches rather than only the first match. |
i | Ignore letter case during matching. |
m | Let ^ and $ match line boundaries. |
s | Let . match line terminators. |
u | Use Unicode-aware pattern interpretation. |
m does not make . match a newline. That is the purpose of s.
Other engines can use different flags or inline modifiers.
Patterns and string literals
The editor expects regex syntax. A programming language can require another layer of escaping around that syntax.
| Location | JavaScript example |
|---|---|
| regex101 pattern field | \bORD-[0-9]{4}\b |
| JavaScript regex literal | /\bORD-[0-9]{4}\b/g |
JavaScript string passed to RegExp | new RegExp('\\bORD-[0-9]{4}\\b', 'g') |
The delimiter marks the outside of a regex literal. It is not part of the text you want to match. A slash inside a slash-delimited literal needs escaping. Other host languages use different quoting rules.
Choose the operation
The Regex Editor overview compares Match, Substitution, Extraction, and Unit Tests.