Skip to main content

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
Compare plans

Configure a match​

  1. Select the engine used by your application.
  2. Select Match mode.
  3. Enter the pattern between the delimiter controls.
  4. Paste the actual text into Test String.
  5. Select the flags required for your task.

For JavaScript, this pattern finds four-digit order identifiers:

\bORD-(?<id>[0-9]{4})\b

Open in regex101

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:

FlagEffect
gFind successive matches rather than only the first match.
iIgnore letter case during matching.
mLet ^ and $ match line boundaries.
sLet . match line terminators.
uUse 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.

LocationJavaScript example
regex101 pattern field\bORD-[0-9]{4}\b
JavaScript regex literal/\bORD-[0-9]{4}\b/g
JavaScript string passed to RegExpnew 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​

Match finds text. Substitution replaces matches and preserves other input. Extraction joins replacement values from matches. Its guide also covers the zero-match display. Unit tests compare results with saved expectations.