Skip to the content.

Engine: Perl

Home | Engines | Reference | Improve this section

Languages

Improve this section

Features

The following features are supported:

The following features are not supported:

Feature: Flags

Main article | Reference | Back to top | Improve this section: 1, 2

Flags control certain aspects of the matching behavior of a pattern.

Syntax

Improve this section

The following flags are supported:

See Also

Improve this section

Feature: Anchors

Main article | Reference | Back to top | Improve this section: 1, 2

Anchors match the start or end of a line.

Syntax

Improve this section

See Also

Improve this section

Feature: Buffer Boundaries

Main article | Reference | Back to top | Improve this section: 1, 2

A Buffer Boundary is an Atom that matches the start or the end of the input. This differs slightly from ^ and $ which can be affected by RegExp flags like m.

Syntax

Improve this section

See Also

Improve this section

Feature: Word Boundaries

Main article | Reference | Back to top | Improve this section: 1, 2

A Word Boundary is an Atom that matches the start or the end of a word.

Syntax

Improve this section

See Also

Improve this section

Feature: Text Segment Boundaries

Main article | Back to top | Improve this section: 1, 2

❌ This feature is not supported.

See Also

Improve this section

Feature: Continuation Escape

Main article | Reference | Back to top | Improve this section: 1, 2

A Continuation Escape is a zero-width assertion that matches either the start of the input or the start of the last match.

Syntax

Improve this section

See Also

Improve this section

Feature: Alternatives

Main article | Reference | Back to top | Improve this section: 1, 2

An Alternative represents two or more branches in a pattern. If first branch of a pattern fails to match, each alternative is attempted from left to right until a match is found.

Syntax

Improve this section

Feature: Wildcard

Main article | Reference | Back to top | Improve this section: 1, 2

A Wildcard matches a single, non-newline character.

Syntax

Improve this section

Feature: Character Classes

Main article | Reference | Back to top | Improve this section: 1, 2

A Character Class is an Atom that specifies a set of characters to match a single character in the set.

Syntax

Improve this section

Extended Bracketed Character Class

Inside of (?[…]), only meta characters are permitted and whitespace is ignored. Individual characters (like a, 1, etc.) must be enclosed in a Character Class Nested Set.

In addition, expressions within the bracketed character class may be grouped using ( and ).

See Also

Improve this section

Feature: Posix Character Classes

Main article | Reference | Back to top | Improve this section: 1, 2

A Posix Character Class is a member of a Character Class set that specifies a named, pre-defined set of characters.

Syntax

Improve this section

See Also

Improve this section

Feature: Negated Posix Character Classes

Main article | Reference | Back to top | Improve this section: 1, 2

A Negated Posix Character Class is a member of a Character Class set that specifies a named, pre-defined set of excluded characters.

Syntax

Improve this section

See Also

Improve this section

Feature: Collating Elements

Main article | Back to top | Improve this section: 1, 2

❌ This feature is not supported.

See Also

Improve this section

Feature: Equivalence Classes

Main article | Back to top | Improve this section: 1, 2

❌ This feature is not supported.

See Also

Improve this section

Feature: Character Class Escapes

Main article | Reference | Back to top | Improve this section: 1, 2

A Character Class Escape is a single character escape that represents an entire character class. They can be used as an element of a Character Class or as an Atom. It is often the case that a lower-case escape character is the inclusive set, while an upper-case variant of the same character excludes that set.

Syntax

Improve this section

See Also

Improve this section

Feature: Line Endings Escape

Main article | Reference | Back to top | Improve this section: 1, 2

A Line Endings Escape is an Atom that matches any line ending character sequence.

Syntax

Improve this section

See Also

Improve this section

Feature: Character Property Escapes

Main article | Reference | Back to top | Improve this section: 1, 2

A Character Property Escape is an escape sequence used to match a character with a specific character property.

Syntax

Improve this section

See Also

Improve this section

Feature: Character Class Nested Set

Main article | Reference | Back to top | Improve this section: 1, 2

A Character Class Nested Set allows you to to define a nested character class inside of a character class.

Syntax

Improve this section

Example

Improve this section

(?[[a-z]&[^d-q]])

Is equivalent to:

[a-cr-z]

See Also

Improve this section

Feature: Character Class Intersection

Main article | Reference | Back to top | Improve this section: 1, 2

Character Class Intersection allows you to indicate that only characters that are in both character classes should match.

Syntax

Improve this section

See Also

Improve this section

Feature: Character Class Union

Main article | Reference | Back to top | Improve this section: 1, 2

Character Class Union allows you include multiple classes of characters within a character class.

Syntax

Improve this section

See Also

Improve this section

Feature: Character Class Subtraction

Main article | Reference | Back to top | Improve this section: 1, 2

Character Class Subtraction allows you to exclude a class of characters from another class of characters in a character class.

Syntax

Improve this section

See Also

Improve this section

Feature: Character Class Symmetric Difference

Main article | Reference | Back to top | Improve this section: 1, 2

Character Class Symmetric Difference allows you include characters that match either, but not both, of two character classes.

Syntax

Improve this section

See Also

Improve this section

Feature: Character Class Complement

Main article | Reference | Back to top | Improve this section: 1, 2

Character Class Complement allows you to negate a character class inside of another character class.

Syntax

Improve this section

See Also

Improve this section

Feature: Quoted Characters

Main article | Reference | Back to top | Improve this section: 1, 2

Quoted Characters are a sequence of characters treated as literal characters rather than RegExp characters.

Syntax

Improve this section

Feature: Quantifiers

Main article | Reference | Back to top | Improve this section: 1, 2

Quantifiers specify repetition of an Atom. By default, quantifiers are “greedy” in that they attempt to match as many instances of the preceding Atom as possible to satisfy the pattern before backtracking.

Syntax

Improve this section

See Also

Improve this section

Feature: Lazy Quantifiers

Main article | Reference | Back to top | Improve this section: 1, 2

Lazy Quantifiers specify repetition of an Atom, but attempt to match as few instances of the preceding Atom as possible to satisfy the pattern before advancing.

Syntax

Improve this section

See Also

Improve this section

Feature: Possessive Quantifiers

Main article | Reference | Back to top | Improve this section: 1, 2

Possessive Quantifiers are like greedy (i.e., regular) quantifiers, except that backtracking is not performed.

Syntax

Improve this section

See Also

Improve this section

Feature: Capturing Groups

Main article | Reference | Back to top | Improve this section: 1, 2

A Capturing Group is a subexpression that can be treated as an Atom and can be repeated using Quantifiers and referenced using Backreferences by index. A Capturing Group can be captured and returned by the matching algorithm.

Syntax

Improve this section

See Also

Improve this section

Feature: Named Capturing Groups

Main article | Reference | Back to top | Improve this section: 1, 2

A Named Capturing Group is a subexpression that can be captured and returned by the matching algorithm. A Named Capturing Group is also an Atom and can be repeated using Quantifiers and referenced using Backreferences by name.

Syntax

Improve this section

See Also

Improve this section

Feature: Non-Capturing Groups

Main article | Reference | Back to top | Improve this section: 1, 2

A Non-capturing Group is a subexpression that can be treated as an Atom and can be repeated using Quantifiers but cannot be referenced using Backreferences. A Non-capturing Group is not captured by the matching algorithm.

Syntax

Improve this section

See Also

Improve this section

Feature: Backreferences

Main article | Reference | Back to top | Improve this section: 1, 2

Backreferences allow a pattern to re-match a previously matched capture group1 2 either by number (n) or by name.

Syntax

Improve this section

See Also

Improve this section

Feature: Comments

Main article | Reference | Back to top | Improve this section: 1, 2

A Comment is a sequence of characters that is ignored by pattern matching and can be used to document a pattern.

Syntax

Improve this section

See Also

Improve this section

Feature: Line Comments

Main article | Reference | Back to top | Improve this section: 1, 2

A Line Comment is a sequence of characters starting with # and ending with \n (or the end of the pattern) that is ignored by pattern matching and can be used to document a pattern.

Syntax

Improve this section

See Also

Improve this section

Feature: Modifiers

Main article | Reference | Back to top | Improve this section: 1, 2

Modifiers allow you to change the currently active RegExp flags within a subexpression.

Syntax

Improve this section

See Also

Improve this section

Feature: Branch Reset

Main article | Reference | Back to top | Improve this section: 1, 2

A Branch Reset resets the subexpression count at the start of each Alternative (|), which affects numbering for Backreferences and captured results returned from the matching algorithm.

Syntax

Improve this section

Feature: Lookahead

Main article | Reference | Back to top | Improve this section: 1, 2

A Lookahead is a zero-width assertion that matches if the provided pattern would match the characters to the right of the current position.

Syntax

Improve this section

See Also

Improve this section

Feature: Lookbehind

Main article | Reference | Back to top | Improve this section: 1, 2

A Lookbehind is a zero-width assertion that matches if the provided pattern would match the characters to the left of the current position.

Syntax

Improve this section

See Also

Improve this section

Feature: Non-Backtracking Expressions

Main article | Reference | Back to top | Improve this section: 1, 2

A Non-Backtracking Expression is matched independent of neighboring patterns, and will not backtrack in the event of a failed match. This is often used to improve performance.

Syntax

Improve this section

Feature: Recursion

Main article | Reference | Back to top | Improve this section: 1, 2

A Recursive Expression provides a mechanism for re-evaluating a capture group inside of itself, to handle cases such as matching balanced parenthesis or brackets, etc.

Syntax

Improve this section

Feature: Conditional Expressions

Main article | Reference | Back to top | Improve this section: 1, 2

A Conditional Expression checks a condition and evaluates its first alternative if the condition is true; otherwise, it evaluates its second alternative.

Syntax

Improve this section

Conditions

The following conditions are supported:

Feature: Subroutines

Main article | Reference | Back to top | Improve this section: 1, 2

A Subroutine is a pre-defined capture group or named capture group that can be reused in multiple places within the pattern to re-evaluate the subexpression from the group.

Syntax

Improve this section

Example

Improve this section

(?(DEFINE)
  (?<Year>\d{4}|[+-]\d{5,})
  (?<Month>0[1-9]|1[0-2])
  (?<Day>0[1-9]|2[0-9]|3[01])
)
(?<Date>(?&Year)-(?&Month)-(?&Day)|(?&Year)(?&Month)(?&Day))

Feature: Callouts

Main article | Reference | Back to top | Improve this section: 1, 2

A Callout is a user-defined function that can be evaluated while matching.

Syntax

Improve this section

Feature: Backtracking Control Verbs

Main article | Reference | Back to top | Improve this section: 1, 2

A Backtracking Control Verb is a special pattern usually in the form of (*VERB) or (*VERB:arg) that performs some special behavior with respect to backtracking.

Syntax

Improve this section