735 lines
38 KiB
HTML
735 lines
38 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of PCRE2SYNTAX</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>PCRE2SYNTAX</H1>
|
|
Section: C Library Functions (3)<BR>Updated: 29 July 2019<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
PCRE2 - Perl-compatible regular expressions (revised API)
|
|
<A NAME="lbAC"> </A>
|
|
<H2>PCRE2 REGULAR EXPRESSION SYNTAX SUMMARY</H2>
|
|
|
|
|
|
<P>
|
|
The full syntax and semantics of the regular expressions that are supported by
|
|
PCRE2 are described in the
|
|
|
|
<B>pcre2pattern</B>
|
|
|
|
documentation. This document contains a quick-reference summary of the syntax.
|
|
<A NAME="lbAD"> </A>
|
|
<H2>QUOTING</H2>
|
|
|
|
|
|
<P>
|
|
<BR> \x where x is non-alphanumeric is a literal x
|
|
<BR> \Q...\E treat enclosed characters as literal
|
|
<A NAME="lbAE"> </A>
|
|
<H2>ESCAPED CHARACTERS</H2>
|
|
|
|
|
|
<P>
|
|
This table applies to ASCII and Unicode environments. An unrecognized escape
|
|
sequence causes an error.
|
|
<P>
|
|
<BR> \a alarm, that is, the BEL character (hex 07)
|
|
<BR> \cx "control-x", where x is any ASCII printing character
|
|
<BR> \e escape (hex 1B)
|
|
<BR> \f form feed (hex 0C)
|
|
<BR> \n newline (hex 0A)
|
|
<BR> \r carriage return (hex 0D)
|
|
<BR> \t tab (hex 09)
|
|
<BR> \0dd character with octal code 0dd
|
|
<BR> \ddd character with octal code ddd, or backreference
|
|
<BR> \o{ddd..} character with octal code ddd..
|
|
<BR> \N{U+hh..} character with Unicode code point hh.. (Unicode mode only)
|
|
<BR> \xhh character with hex code hh
|
|
<BR> \x{hh..} character with hex code hh..
|
|
<P>
|
|
If PCRE2_ALT_BSUX or PCRE2_EXTRA_ALT_BSUX is set ("ALT_BSUX mode"), the
|
|
following are also recognized:
|
|
<P>
|
|
<BR> \U the character "U"
|
|
<BR> \uhhhh character with hex code hhhh
|
|
<BR> \u{hh..} character with hex code hh.. but only for EXTRA_ALT_BSUX
|
|
<P>
|
|
When \x is not followed by {, from zero to two hexadecimal digits are read,
|
|
but in ALT_BSUX mode \x must be followed by two hexadecimal digits to be
|
|
recognized as a hexadecimal escape; otherwise it matches a literal "x".
|
|
Likewise, if \u (in ALT_BSUX mode) is not followed by four hexadecimal digits
|
|
or (in EXTRA_ALT_BSUX mode) a sequence of hex digits in curly brackets, it
|
|
matches a literal "u".
|
|
<P>
|
|
|
|
Note that \0dd is always an octal code. The treatment of backslash followed by
|
|
a non-zero digit is complicated; for details see the section
|
|
|
|
|
|
"Non-printing characters"
|
|
|
|
in the
|
|
|
|
<B>pcre2pattern</B>
|
|
|
|
documentation, where details of escape processing in EBCDIC environments are
|
|
also given. \N{U+hh..} is synonymous with \x{hh..} in PCRE2 but is not
|
|
supported in EBCDIC environments. Note that \N not followed by an opening
|
|
curly bracket has a different meaning (see below).
|
|
<A NAME="lbAF"> </A>
|
|
<H2>CHARACTER TYPES</H2>
|
|
|
|
|
|
<P>
|
|
<BR> . any character except newline;
|
|
<BR> in dotall mode, any character whatsoever
|
|
<BR> \C one code unit, even in UTF mode (best avoided)
|
|
<BR> \d a decimal digit
|
|
<BR> \D a character that is not a decimal digit
|
|
<BR> \h a horizontal white space character
|
|
<BR> \H a character that is not a horizontal white space character
|
|
<BR> \N a character that is not a newline
|
|
<BR> \p{<I>xx</I>} a character with the <I>xx</I> property
|
|
<BR> \P{<I>xx</I>} a character without the <I>xx</I> property
|
|
<BR> \R a newline sequence
|
|
<BR> \s a white space character
|
|
<BR> \S a character that is not a white space character
|
|
<BR> \v a vertical white space character
|
|
<BR> \V a character that is not a vertical white space character
|
|
<BR> \w a "word" character
|
|
<BR> \W a "non-word" character
|
|
<BR> \X a Unicode extended grapheme cluster
|
|
<P>
|
|
\C is dangerous because it may leave the current matching point in the middle
|
|
of a UTF-8 or UTF-16 character. The application can lock out the use of \C by
|
|
setting the PCRE2_NEVER_BACKSLASH_C option. It is also possible to build PCRE2
|
|
with the use of \C permanently disabled.
|
|
<P>
|
|
|
|
By default, \d, \s, and \w match only ASCII characters, even in UTF-8 mode
|
|
or in the 16-bit and 32-bit libraries. However, if locale-specific matching is
|
|
happening, \s and \w may also match characters with code points in the range
|
|
128-255. If the PCRE2_UCP option is set, the behaviour of these escape
|
|
sequences is changed to use Unicode properties and they match many more
|
|
characters.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>GENERAL CATEGORY PROPERTIES FOR \p and \P</H2>
|
|
|
|
|
|
<P>
|
|
<BR> C Other
|
|
<BR> Cc Control
|
|
<BR> Cf Format
|
|
<BR> Cn Unassigned
|
|
<BR> Co Private use
|
|
<BR> Cs Surrogate
|
|
<P>
|
|
<BR> L Letter
|
|
<BR> Ll Lower case letter
|
|
<BR> Lm Modifier letter
|
|
<BR> Lo Other letter
|
|
<BR> Lt Title case letter
|
|
<BR> Lu Upper case letter
|
|
<BR> L& Ll, Lu, or Lt
|
|
<P>
|
|
<BR> M Mark
|
|
<BR> Mc Spacing mark
|
|
<BR> Me Enclosing mark
|
|
<BR> Mn Non-spacing mark
|
|
<P>
|
|
<BR> N Number
|
|
<BR> Nd Decimal number
|
|
<BR> Nl Letter number
|
|
<BR> No Other number
|
|
<P>
|
|
<BR> P Punctuation
|
|
<BR> Pc Connector punctuation
|
|
<BR> Pd Dash punctuation
|
|
<BR> Pe Close punctuation
|
|
<BR> Pf Final punctuation
|
|
<BR> Pi Initial punctuation
|
|
<BR> Po Other punctuation
|
|
<BR> Ps Open punctuation
|
|
<P>
|
|
<BR> S Symbol
|
|
<BR> Sc Currency symbol
|
|
<BR> Sk Modifier symbol
|
|
<BR> Sm Mathematical symbol
|
|
<BR> So Other symbol
|
|
<P>
|
|
<BR> Z Separator
|
|
<BR> Zl Line separator
|
|
<BR> Zp Paragraph separator
|
|
<BR> Zs Space separator
|
|
<A NAME="lbAH"> </A>
|
|
<H2>PCRE2 SPECIAL CATEGORY PROPERTIES FOR \p and \P</H2>
|
|
|
|
|
|
<P>
|
|
<BR> Xan Alphanumeric: union of properties L and N
|
|
<BR> Xps POSIX space: property Z or tab, NL, VT, FF, CR
|
|
<BR> Xsp Perl space: property Z or tab, NL, VT, FF, CR
|
|
<BR> Xuc Univerally-named character: one that can be
|
|
<BR> represented by a Universal Character Name
|
|
<BR> Xwd Perl word: property Xan or underscore
|
|
<P>
|
|
Perl and POSIX space are now the same. Perl added VT to its space character set
|
|
at release 5.18.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SCRIPT NAMES FOR \p AND \P</H2>
|
|
|
|
|
|
<P>
|
|
Adlam,
|
|
Ahom,
|
|
Anatolian_Hieroglyphs,
|
|
Arabic,
|
|
Armenian,
|
|
Avestan,
|
|
Balinese,
|
|
Bamum,
|
|
Bassa_Vah,
|
|
Batak,
|
|
Bengali,
|
|
Bhaiksuki,
|
|
Bopomofo,
|
|
Brahmi,
|
|
Braille,
|
|
Buginese,
|
|
Buhid,
|
|
Canadian_Aboriginal,
|
|
Carian,
|
|
Caucasian_Albanian,
|
|
Chakma,
|
|
Cham,
|
|
Cherokee,
|
|
Common,
|
|
Coptic,
|
|
Cuneiform,
|
|
Cypriot,
|
|
Cyrillic,
|
|
Deseret,
|
|
Devanagari,
|
|
Dogra,
|
|
Duployan,
|
|
Egyptian_Hieroglyphs,
|
|
Elbasan,
|
|
Elymaic,
|
|
Ethiopic,
|
|
Georgian,
|
|
Glagolitic,
|
|
Gothic,
|
|
Grantha,
|
|
Greek,
|
|
Gujarati,
|
|
Gunjala_Gondi,
|
|
Gurmukhi,
|
|
Han,
|
|
Hangul,
|
|
Hanifi_Rohingya,
|
|
Hanunoo,
|
|
Hatran,
|
|
Hebrew,
|
|
Hiragana,
|
|
Imperial_Aramaic,
|
|
Inherited,
|
|
Inscriptional_Pahlavi,
|
|
Inscriptional_Parthian,
|
|
Javanese,
|
|
Kaithi,
|
|
Kannada,
|
|
Katakana,
|
|
Kayah_Li,
|
|
Kharoshthi,
|
|
Khmer,
|
|
Khojki,
|
|
Khudawadi,
|
|
Lao,
|
|
Latin,
|
|
Lepcha,
|
|
Limbu,
|
|
Linear_A,
|
|
Linear_B,
|
|
Lisu,
|
|
Lycian,
|
|
Lydian,
|
|
Mahajani,
|
|
Makasar,
|
|
Malayalam,
|
|
Mandaic,
|
|
Manichaean,
|
|
Marchen,
|
|
Masaram_Gondi,
|
|
Medefaidrin,
|
|
Meetei_Mayek,
|
|
Mende_Kikakui,
|
|
Meroitic_Cursive,
|
|
Meroitic_Hieroglyphs,
|
|
Miao,
|
|
Modi,
|
|
Mongolian,
|
|
Mro,
|
|
Multani,
|
|
Myanmar,
|
|
Nabataean,
|
|
Nandinagari,
|
|
New_Tai_Lue,
|
|
Newa,
|
|
Nko,
|
|
Nushu,
|
|
Nyakeng_Puachue_Hmong,
|
|
Ogham,
|
|
Ol_Chiki,
|
|
Old_Hungarian,
|
|
Old_Italic,
|
|
Old_North_Arabian,
|
|
Old_Permic,
|
|
Old_Persian,
|
|
Old_Sogdian,
|
|
Old_South_Arabian,
|
|
Old_Turkic,
|
|
Oriya,
|
|
Osage,
|
|
Osmanya,
|
|
Pahawh_Hmong,
|
|
Palmyrene,
|
|
Pau_Cin_Hau,
|
|
Phags_Pa,
|
|
Phoenician,
|
|
Psalter_Pahlavi,
|
|
Rejang,
|
|
Runic,
|
|
Samaritan,
|
|
Saurashtra,
|
|
Sharada,
|
|
Shavian,
|
|
Siddham,
|
|
SignWriting,
|
|
Sinhala,
|
|
Sogdian,
|
|
Sora_Sompeng,
|
|
Soyombo,
|
|
Sundanese,
|
|
Syloti_Nagri,
|
|
Syriac,
|
|
Tagalog,
|
|
Tagbanwa,
|
|
Tai_Le,
|
|
Tai_Tham,
|
|
Tai_Viet,
|
|
Takri,
|
|
Tamil,
|
|
Tangut,
|
|
Telugu,
|
|
Thaana,
|
|
Thai,
|
|
Tibetan,
|
|
Tifinagh,
|
|
Tirhuta,
|
|
Ugaritic,
|
|
Vai,
|
|
Wancho,
|
|
Warang_Citi,
|
|
Yi,
|
|
Zanabazar_Square.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>CHARACTER CLASSES</H2>
|
|
|
|
|
|
<P>
|
|
<BR> [...] positive character class
|
|
<BR> [^...] negative character class
|
|
<BR> [x-y] range (can be used for hex characters)
|
|
<BR> [[:xxx:]] positive POSIX named set
|
|
<BR> [[:^xxx:]] negative POSIX named set
|
|
<P>
|
|
<BR> alnum alphanumeric
|
|
<BR> alpha alphabetic
|
|
<BR> ascii 0-127
|
|
<BR> blank space or tab
|
|
<BR> cntrl control character
|
|
<BR> digit decimal digit
|
|
<BR> graph printing, excluding space
|
|
<BR> lower lower case letter
|
|
<BR> print printing, including space
|
|
<BR> punct printing, excluding alphanumeric
|
|
<BR> space white space
|
|
<BR> upper upper case letter
|
|
<BR> word same as \w
|
|
<BR> xdigit hexadecimal digit
|
|
<P>
|
|
In PCRE2, POSIX character set names recognize only ASCII characters by default,
|
|
but some of them use Unicode properties if PCRE2_UCP is set. You can use
|
|
\Q...\E inside a character class.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>QUANTIFIERS</H2>
|
|
|
|
|
|
<P>
|
|
<BR> ? 0 or 1, greedy
|
|
<BR> ?+ 0 or 1, possessive
|
|
<BR> ?? 0 or 1, lazy
|
|
<BR> * 0 or more, greedy
|
|
<BR> *+ 0 or more, possessive
|
|
<BR> *? 0 or more, lazy
|
|
<BR> + 1 or more, greedy
|
|
<BR> ++ 1 or more, possessive
|
|
<BR> +? 1 or more, lazy
|
|
<BR> {n} exactly n
|
|
<BR> {n,m} at least n, no more than m, greedy
|
|
<BR> {n,m}+ at least n, no more than m, possessive
|
|
<BR> {n,m}? at least n, no more than m, lazy
|
|
<BR> {n,} n or more, greedy
|
|
<BR> {n,}+ n or more, possessive
|
|
<BR> {n,}? n or more, lazy
|
|
<A NAME="lbAL"> </A>
|
|
<H2>ANCHORS AND SIMPLE ASSERTIONS</H2>
|
|
|
|
|
|
<P>
|
|
<BR> \b word boundary
|
|
<BR> \B not a word boundary
|
|
<BR> ^ start of subject
|
|
<BR> also after an internal newline in multiline mode
|
|
<BR> (after any newline if PCRE2_ALT_CIRCUMFLEX is set)
|
|
<BR> \A start of subject
|
|
<BR> $ end of subject
|
|
<BR> also before newline at end of subject
|
|
<BR> also before internal newline in multiline mode
|
|
<BR> \Z end of subject
|
|
<BR> also before newline at end of subject
|
|
<BR> \z end of subject
|
|
<BR> \G first matching position in subject
|
|
<A NAME="lbAM"> </A>
|
|
<H2>REPORTED MATCH POINT SETTING</H2>
|
|
|
|
|
|
<P>
|
|
<BR> \K set reported start of match
|
|
<P>
|
|
\K is honoured in positive assertions, but ignored in negative ones.
|
|
<A NAME="lbAN"> </A>
|
|
<H2>ALTERNATION</H2>
|
|
|
|
|
|
<P>
|
|
<BR> expr|expr|expr...
|
|
<A NAME="lbAO"> </A>
|
|
<H2>CAPTURING</H2>
|
|
|
|
|
|
<P>
|
|
<BR> (...) capture group
|
|
<BR> (?<name>...) named capture group (Perl)
|
|
<BR> (?'name'...) named capture group (Perl)
|
|
<BR> (?P<name>...) named capture group (Python)
|
|
<BR> (?:...) non-capture group
|
|
<BR> (?|...) non-capture group; reset group numbers for
|
|
<BR> capture groups in each alternative
|
|
<P>
|
|
In non-UTF modes, names may contain underscores and ASCII letters and digits;
|
|
in UTF modes, any Unicode letters and Unicode decimal digits are permitted. In
|
|
both cases, a name must not start with a digit.
|
|
<A NAME="lbAP"> </A>
|
|
<H2>ATOMIC GROUPS</H2>
|
|
|
|
|
|
<P>
|
|
<BR> (?>...) atomic non-capture group
|
|
<BR> (*atomic:...) atomic non-capture group
|
|
<A NAME="lbAQ"> </A>
|
|
<H2>COMMENT</H2>
|
|
|
|
|
|
<P>
|
|
<BR> (?#....) comment (not nestable)
|
|
<A NAME="lbAR"> </A>
|
|
<H2>OPTION SETTING</H2>
|
|
|
|
|
|
Changes of these options within a group are automatically cancelled at the end
|
|
of the group.
|
|
<P>
|
|
<BR> (?i) caseless
|
|
<BR> (?J) allow duplicate names
|
|
<BR> (?m) multiline
|
|
<BR> (?n) no auto capture
|
|
<BR> (?s) single line (dotall)
|
|
<BR> (?U) default ungreedy (lazy)
|
|
<BR> (?x) extended: ignore white space except in classes
|
|
<BR> (?xx) as (?x) but also ignore space and tab in classes
|
|
<BR> (?-...) unset option(s)
|
|
<BR> (?^) unset imnsx options
|
|
<P>
|
|
Unsetting x or xx unsets both. Several options may be set at once, and a
|
|
mixture of setting and unsetting such as (?i-x) is allowed, but there may be
|
|
only one hyphen. Setting (but no unsetting) is allowed after (?^ for example
|
|
(?^in). An option setting may appear at the start of a non-capture group, for
|
|
example (?i:...).
|
|
<P>
|
|
|
|
The following are recognized only at the very start of a pattern or after one
|
|
of the newline or \R options with similar syntax. More than one of them may
|
|
appear. For the first three, d is a decimal number.
|
|
<P>
|
|
<BR> (*LIMIT_DEPTH=d) set the backtracking limit to d
|
|
<BR> (*LIMIT_HEAP=d) set the heap size limit to d * 1024 bytes
|
|
<BR> (*LIMIT_MATCH=d) set the match limit to d
|
|
<BR> (*NOTEMPTY) set PCRE2_NOTEMPTY when matching
|
|
<BR> (*NOTEMPTY_ATSTART) set PCRE2_NOTEMPTY_ATSTART when matching
|
|
<BR> (*NO_AUTO_POSSESS) no auto-possessification (PCRE2_NO_AUTO_POSSESS)
|
|
<BR> (*NO_DOTSTAR_ANCHOR) no .* anchoring (PCRE2_NO_DOTSTAR_ANCHOR)
|
|
<BR> (*NO_JIT) disable JIT optimization
|
|
<BR> (*NO_START_OPT) no start-match optimization (PCRE2_NO_START_OPTIMIZE)
|
|
<BR> (*UTF) set appropriate UTF mode for the library in use
|
|
<BR> (*UCP) set PCRE2_UCP (use Unicode properties for \d etc)
|
|
<P>
|
|
Note that LIMIT_DEPTH, LIMIT_HEAP, and LIMIT_MATCH can only reduce the value of
|
|
the limits set by the caller of <B>pcre2_match()</B> or <B>pcre2_dfa_match()</B>,
|
|
not increase them. LIMIT_RECURSION is an obsolete synonym for LIMIT_DEPTH. The
|
|
application can lock out the use of (*UTF) and (*UCP) by setting the
|
|
PCRE2_NEVER_UTF or PCRE2_NEVER_UCP options, respectively, at compile time.
|
|
<A NAME="lbAS"> </A>
|
|
<H2>NEWLINE CONVENTION</H2>
|
|
|
|
|
|
<P>
|
|
These are recognized only at the very start of the pattern or after option
|
|
settings with a similar syntax.
|
|
<P>
|
|
<BR> (*CR) carriage return only
|
|
<BR> (*LF) linefeed only
|
|
<BR> (*CRLF) carriage return followed by linefeed
|
|
<BR> (*ANYCRLF) all three of the above
|
|
<BR> (*ANY) any Unicode newline sequence
|
|
<BR> (*NUL) the NUL character (binary zero)
|
|
<A NAME="lbAT"> </A>
|
|
<H2>WHAT \R MATCHES</H2>
|
|
|
|
|
|
<P>
|
|
These are recognized only at the very start of the pattern or after option
|
|
setting with a similar syntax.
|
|
<P>
|
|
<BR> (*BSR_ANYCRLF) CR, LF, or CRLF
|
|
<BR> (*BSR_UNICODE) any Unicode newline sequence
|
|
<A NAME="lbAU"> </A>
|
|
<H2>LOOKAHEAD AND LOOKBEHIND ASSERTIONS</H2>
|
|
|
|
|
|
<P>
|
|
<BR> (?=...) )
|
|
<BR> (*pla:...) ) positive lookahead
|
|
<BR> (*positive_lookahead:...) )
|
|
<P>
|
|
<BR> (?!...) )
|
|
<BR> (*nla:...) ) negative lookahead
|
|
<BR> (*negative_lookahead:...) )
|
|
<P>
|
|
<BR> (?<=...) )
|
|
<BR> (*plb:...) ) positive lookbehind
|
|
<BR> (*positive_lookbehind:...) )
|
|
<P>
|
|
<BR> (?<!...) )
|
|
<BR> (*nlb:...) ) negative lookbehind
|
|
<BR> (*negative_lookbehind:...) )
|
|
<P>
|
|
Each top-level branch of a lookbehind must be of a fixed length.
|
|
<A NAME="lbAV"> </A>
|
|
<H2>NON-ATOMIC LOOKAROUND ASSERTIONS</H2>
|
|
|
|
|
|
<P>
|
|
These assertions are specific to PCRE2 and are not Perl-compatible.
|
|
<P>
|
|
<BR> (*napla:...)
|
|
<BR> (*non_atomic_positive_lookahead:...)
|
|
<P>
|
|
<BR> (*naplb:...)
|
|
<BR> (*non_atomic_positive_lookbehind:...)
|
|
<A NAME="lbAW"> </A>
|
|
<H2>SCRIPT RUNS</H2>
|
|
|
|
|
|
<P>
|
|
<BR> (*script_run:...) ) script run, can be backtracked into
|
|
<BR> (*sr:...) )
|
|
<P>
|
|
<BR> (*atomic_script_run:...) ) atomic script run
|
|
<BR> (*asr:...) )
|
|
<A NAME="lbAX"> </A>
|
|
<H2>BACKREFERENCES</H2>
|
|
|
|
|
|
<P>
|
|
<BR> \n reference by number (can be ambiguous)
|
|
<BR> \gn reference by number
|
|
<BR> \g{n} reference by number
|
|
<BR> \g+n relative reference by number (PCRE2 extension)
|
|
<BR> \g-n relative reference by number
|
|
<BR> \g{+n} relative reference by number (PCRE2 extension)
|
|
<BR> \g{-n} relative reference by number
|
|
<BR> \k<name> reference by name (Perl)
|
|
<BR> \k'name' reference by name (Perl)
|
|
<BR> \g{name} reference by name (Perl)
|
|
<BR> \k{name} reference by name (.NET)
|
|
<BR> (?P=name) reference by name (Python)
|
|
<A NAME="lbAY"> </A>
|
|
<H2>SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)</H2>
|
|
|
|
|
|
<P>
|
|
<BR> (?R) recurse whole pattern
|
|
<BR> (?n) call subroutine by absolute number
|
|
<BR> (?+n) call subroutine by relative number
|
|
<BR> (?-n) call subroutine by relative number
|
|
<BR> (?&name) call subroutine by name (Perl)
|
|
<BR> (?P>name) call subroutine by name (Python)
|
|
<BR> \g<name> call subroutine by name (Oniguruma)
|
|
<BR> \g'name' call subroutine by name (Oniguruma)
|
|
<BR> \g<n> call subroutine by absolute number (Oniguruma)
|
|
<BR> \g'n' call subroutine by absolute number (Oniguruma)
|
|
<BR> \g<+n> call subroutine by relative number (PCRE2 extension)
|
|
<BR> \g'+n' call subroutine by relative number (PCRE2 extension)
|
|
<BR> \g<-n> call subroutine by relative number (PCRE2 extension)
|
|
<BR> \g'-n' call subroutine by relative number (PCRE2 extension)
|
|
<A NAME="lbAZ"> </A>
|
|
<H2>CONDITIONAL PATTERNS</H2>
|
|
|
|
|
|
<P>
|
|
<BR> (?(condition)yes-pattern)
|
|
<BR> (?(condition)yes-pattern|no-pattern)
|
|
<P>
|
|
<BR> (?(n) absolute reference condition
|
|
<BR> (?(+n) relative reference condition
|
|
<BR> (?(-n) relative reference condition
|
|
<BR> (?(<name>) named reference condition (Perl)
|
|
<BR> (?('name') named reference condition (Perl)
|
|
<BR> (?(name) named reference condition (PCRE2, deprecated)
|
|
<BR> (?(R) overall recursion condition
|
|
<BR> (?(Rn) specific numbered group recursion condition
|
|
<BR> (?(R&name) specific named group recursion condition
|
|
<BR> (?(DEFINE) define groups for reference
|
|
<BR> (?(VERSION[>]=n.m) test PCRE2 version
|
|
<BR> (?(assert) assertion condition
|
|
<P>
|
|
Note the ambiguity of (?(R) and (?(Rn) which might be named reference
|
|
conditions or recursion tests. Such a condition is interpreted as a reference
|
|
condition if the relevant named group exists.
|
|
<A NAME="lbBA"> </A>
|
|
<H2>BACKTRACKING CONTROL</H2>
|
|
|
|
|
|
<P>
|
|
All backtracking control verbs may be in the form (*VERB:NAME). For (*MARK) the
|
|
name is mandatory, for the others it is optional. (*SKIP) changes its behaviour
|
|
if :NAME is present. The others just set a name for passing back to the caller,
|
|
but this is not a name that (*SKIP) can see. The following act immediately they
|
|
are reached:
|
|
<P>
|
|
<BR> (*ACCEPT) force successful match
|
|
<BR> (*FAIL) force backtrack; synonym (*F)
|
|
<BR> (*MARK:NAME) set name to be passed back; synonym (*:NAME)
|
|
<P>
|
|
The following act only when a subsequent match failure causes a backtrack to
|
|
reach them. They all force a match failure, but they differ in what happens
|
|
afterwards. Those that advance the start-of-match point do so only if the
|
|
pattern is not anchored.
|
|
<P>
|
|
<BR> (*COMMIT) overall failure, no advance of starting point
|
|
<BR> (*PRUNE) advance to next starting character
|
|
<BR> (*SKIP) advance to current matching position
|
|
<BR> (*SKIP:NAME) advance to position corresponding to an earlier
|
|
<BR> (*MARK:NAME); if not found, the (*SKIP) is ignored
|
|
<BR> (*THEN) local failure, backtrack to next alternation
|
|
<P>
|
|
The effect of one of these verbs in a group called as a subroutine is confined
|
|
to the subroutine call.
|
|
<A NAME="lbBB"> </A>
|
|
<H2>CALLOUTS</H2>
|
|
|
|
|
|
<P>
|
|
<BR> (?C) callout (assumed number 0)
|
|
<BR> (?Cn) callout with numerical data n
|
|
<BR> (?C"text") callout with string data
|
|
<P>
|
|
The allowed string delimiters are ` ' " ^ % # $ (which are the same for the
|
|
start and the end), and the starting delimiter { matched with the ending
|
|
delimiter }. To encode the ending delimiter within the string, double it.
|
|
<A NAME="lbBC"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
<P>
|
|
<B><A HREF="/cgi-bin/man/man2html?3+pcre2pattern">pcre2pattern</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+pcre2api">pcre2api</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+pcre2callout">pcre2callout</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+pcre2matching">pcre2matching</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+pcre2">pcre2</A></B>(3).
|
|
<A NAME="lbBD"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
<P>
|
|
<PRE>
|
|
Philip Hazel
|
|
University Computing Service
|
|
Cambridge, England.
|
|
</PRE>
|
|
|
|
<A NAME="lbBE"> </A>
|
|
<H2>REVISION</H2>
|
|
|
|
|
|
<P>
|
|
<PRE>
|
|
Last updated: 29 July 2019
|
|
Copyright (c) 1997-2019 University of Cambridge.
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">PCRE2 REGULAR EXPRESSION SYNTAX SUMMARY</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">QUOTING</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">ESCAPED CHARACTERS</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">CHARACTER TYPES</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">GENERAL CATEGORY PROPERTIES FOR \p and \P</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">PCRE2 SPECIAL CATEGORY PROPERTIES FOR \p and \P</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">SCRIPT NAMES FOR \p AND \P</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">CHARACTER CLASSES</A><DD>
|
|
<DT id="10"><A HREF="#lbAK">QUANTIFIERS</A><DD>
|
|
<DT id="11"><A HREF="#lbAL">ANCHORS AND SIMPLE ASSERTIONS</A><DD>
|
|
<DT id="12"><A HREF="#lbAM">REPORTED MATCH POINT SETTING</A><DD>
|
|
<DT id="13"><A HREF="#lbAN">ALTERNATION</A><DD>
|
|
<DT id="14"><A HREF="#lbAO">CAPTURING</A><DD>
|
|
<DT id="15"><A HREF="#lbAP">ATOMIC GROUPS</A><DD>
|
|
<DT id="16"><A HREF="#lbAQ">COMMENT</A><DD>
|
|
<DT id="17"><A HREF="#lbAR">OPTION SETTING</A><DD>
|
|
<DT id="18"><A HREF="#lbAS">NEWLINE CONVENTION</A><DD>
|
|
<DT id="19"><A HREF="#lbAT">WHAT \R MATCHES</A><DD>
|
|
<DT id="20"><A HREF="#lbAU">LOOKAHEAD AND LOOKBEHIND ASSERTIONS</A><DD>
|
|
<DT id="21"><A HREF="#lbAV">NON-ATOMIC LOOKAROUND ASSERTIONS</A><DD>
|
|
<DT id="22"><A HREF="#lbAW">SCRIPT RUNS</A><DD>
|
|
<DT id="23"><A HREF="#lbAX">BACKREFERENCES</A><DD>
|
|
<DT id="24"><A HREF="#lbAY">SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)</A><DD>
|
|
<DT id="25"><A HREF="#lbAZ">CONDITIONAL PATTERNS</A><DD>
|
|
<DT id="26"><A HREF="#lbBA">BACKTRACKING CONTROL</A><DD>
|
|
<DT id="27"><A HREF="#lbBB">CALLOUTS</A><DD>
|
|
<DT id="28"><A HREF="#lbBC">SEE ALSO</A><DD>
|
|
<DT id="29"><A HREF="#lbBD">AUTHOR</A><DD>
|
|
<DT id="30"><A HREF="#lbBE">REVISION</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:51 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|