Skip to the content.

Feature: Subroutines

Home | Features | Improve this section

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

NOTE: The following syntax is an example based on some of the supported engines. For specific engine support, see Engines.

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

Engines

Engine Supported
Perl
PCRE
Boost.Regex
.NET
Oniguruma
Hyperscan
ICU
Glib/GRegex
ECMAScript