Engine: Oniguruma

Home |Engines |Reference |Improve this section

Languages

Improve this section

Features

The following features are supported:

The following features arenot 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:

Some flags depend on options provided to Onigurumareference:

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

ABuffer Boundary is anAtom that matches the start or the end of the input. This differs slightly from^ and$ which can be affected byRegExp flags likem.

Syntax

Improve this section

See Also

Improve this section

Feature: Word Boundaries

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

AWord Boundary is anAtom 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 |Reference |Back to top |Improve this section:1,2

AText Segment Boundary is anAtom that matches the start or the end of a text segment.

Syntax

Improve this section

See Also

Improve this section

Feature: Continuation Escape

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

AContinuation 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

AnAlternative 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

AWildcard matches a single, non-newline character.

Syntax

Improve this section

Feature: Character Classes

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

ACharacter Class is anAtom that specifies a set of characters to match a single character in the set.

Syntax

Improve this section

See Also

Improve this section

Feature: Posix Character Classes

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

APosix Character Class is a member of aCharacter 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

ANegated Posix Character Class is a member of aCharacter 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

ACharacter Class Escape is a single character escape that represents an entire character class. They can be used as an element of aCharacter Class or as anAtom. 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

ALine Endings Escape is anAtom 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

ACharacter 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

ACharacter Class Nested Set allows you to to define a nestedcharacter class inside of acharacter 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 bothcharacter classes should match.

Syntax

Improve this section

See Also

Improve this section

Feature: Character Class Union

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

❌ This feature is not supported.

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 acharacter class.

NOTE: Oniguruma does not support character class subtraction directly, instead you must use a combination ofcharacter class intersections andcharacter class nested sets

Example

Improve this section

[a-w&&[^c-g]z]

Is equivalent to the following pseudo pattern:

([a-w] AND ([^c-g] OR z))

Which reduces to:

[abh-w]

Source for this example comes from Oniguruma:source

See Also

Improve this section

Feature: Character Class Symmetric Difference

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

❌ This feature is not supported.

See Also

Improve this section

Feature: Character Class Complement

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

❌ This feature is not supported.

See Also

Improve this section

Feature: Quoted Characters

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

❌ This feature is not supported.

Feature: Quantifiers

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

Quantifiers specify repetition of anAtom. By default, quantifiers are “greedy” in that they attempt to match as many instances of the precedingAtom 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 anAtom, but attempt to match as few instances of the precedingAtom 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

ACapturing Group is a subexpression that can be treated as anAtom and can be repeated usingQuantifiers and referenced usingBackreferences 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

ANamed Capturing Group is a subexpression that can be captured and returned by the matching algorithm. A Named Capturing Group is also anAtom and can be repeated usingQuantifiers and referenced usingBackreferences 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

ANon-capturing Group is a subexpression that can be treated as anAtom and can be repeated usingQuantifiers but cannot be referenced usingBackreferences. 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 group12 either by number (n) or byname.

Syntax

Improve this section

See Also

Improve this section

Feature: Comments

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

AComment 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 |Back to top |Improve this section:1,2

❌ This feature is not supported.

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 activeRegExp flags within a subexpression.

Syntax

Improve this section

See Also

Improve this section

Feature: Branch Reset

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

❌ This feature is not supported.

Feature: Lookahead

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

ALookahead 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

ALookbehind 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

ANon-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

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

Syntax

Improve this section

NOTE: Left-most recursive calls are forbidden:

Source for this example comes from Oniguruma:source

Feature: Conditional Expressions

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

AConditional Expression checks a condition and evaluates its first alternative if the condition istrue; 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

ASubroutine is a pre-definedcapture group ornamed 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

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

Syntax

Improve this section

Feature: Backtracking Control Verbs

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

❌ This feature is not supported.