github的一些开源项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

635 lines
24 KiB

  1. <html>
  2. <head>
  3. <title>pcre2syntax specification</title>
  4. </head>
  5. <body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
  6. <h1>pcre2syntax man page</h1>
  7. <p>
  8. Return to the <a href="index.html">PCRE2 index page</a>.
  9. </p>
  10. <p>
  11. This page is part of the PCRE2 HTML documentation. It was generated
  12. automatically from the original man page. If there is any nonsense in it,
  13. please consult the man page, in case the conversion went wrong.
  14. <br>
  15. <ul>
  16. <li><a name="TOC1" href="#SEC1">PCRE2 REGULAR EXPRESSION SYNTAX SUMMARY</a>
  17. <li><a name="TOC2" href="#SEC2">QUOTING</a>
  18. <li><a name="TOC3" href="#SEC3">BRACED ITEMS</a>
  19. <li><a name="TOC4" href="#SEC4">ESCAPED CHARACTERS</a>
  20. <li><a name="TOC5" href="#SEC5">CHARACTER TYPES</a>
  21. <li><a name="TOC6" href="#SEC6">GENERAL CATEGORY PROPERTIES FOR \p and \P</a>
  22. <li><a name="TOC7" href="#SEC7">PCRE2 SPECIAL CATEGORY PROPERTIES FOR \p and \P</a>
  23. <li><a name="TOC8" href="#SEC8">BINARY PROPERTIES FOR \p AND \P</a>
  24. <li><a name="TOC9" href="#SEC9">SCRIPT MATCHING WITH \p AND \P</a>
  25. <li><a name="TOC10" href="#SEC10">THE BIDI_CLASS PROPERTY FOR \p AND \P</a>
  26. <li><a name="TOC11" href="#SEC11">CHARACTER CLASSES</a>
  27. <li><a name="TOC12" href="#SEC12">QUANTIFIERS</a>
  28. <li><a name="TOC13" href="#SEC13">ANCHORS AND SIMPLE ASSERTIONS</a>
  29. <li><a name="TOC14" href="#SEC14">REPORTED MATCH POINT SETTING</a>
  30. <li><a name="TOC15" href="#SEC15">ALTERNATION</a>
  31. <li><a name="TOC16" href="#SEC16">CAPTURING</a>
  32. <li><a name="TOC17" href="#SEC17">ATOMIC GROUPS</a>
  33. <li><a name="TOC18" href="#SEC18">COMMENT</a>
  34. <li><a name="TOC19" href="#SEC19">OPTION SETTING</a>
  35. <li><a name="TOC20" href="#SEC20">NEWLINE CONVENTION</a>
  36. <li><a name="TOC21" href="#SEC21">WHAT \R MATCHES</a>
  37. <li><a name="TOC22" href="#SEC22">LOOKAHEAD AND LOOKBEHIND ASSERTIONS</a>
  38. <li><a name="TOC23" href="#SEC23">NON-ATOMIC LOOKAROUND ASSERTIONS</a>
  39. <li><a name="TOC24" href="#SEC24">SCRIPT RUNS</a>
  40. <li><a name="TOC25" href="#SEC25">BACKREFERENCES</a>
  41. <li><a name="TOC26" href="#SEC26">SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)</a>
  42. <li><a name="TOC27" href="#SEC27">CONDITIONAL PATTERNS</a>
  43. <li><a name="TOC28" href="#SEC28">BACKTRACKING CONTROL</a>
  44. <li><a name="TOC29" href="#SEC29">CALLOUTS</a>
  45. <li><a name="TOC30" href="#SEC30">SEE ALSO</a>
  46. <li><a name="TOC31" href="#SEC31">AUTHOR</a>
  47. <li><a name="TOC32" href="#SEC32">REVISION</a>
  48. </ul>
  49. <br><a name="SEC1" href="#TOC1">PCRE2 REGULAR EXPRESSION SYNTAX SUMMARY</a><br>
  50. <P>
  51. The full syntax and semantics of the regular expressions that are supported by
  52. PCRE2 are described in the
  53. <a href="pcre2pattern.html"><b>pcre2pattern</b></a>
  54. documentation. This document contains a quick-reference summary of the syntax.
  55. </P>
  56. <br><a name="SEC2" href="#TOC1">QUOTING</a><br>
  57. <P>
  58. <pre>
  59. \x where x is non-alphanumeric is a literal x
  60. \Q...\E treat enclosed characters as literal
  61. </pre>
  62. Note that white space inside \Q...\E is always treated as literal, even if
  63. PCRE2_EXTENDED is set, causing most other white space to be ignored.
  64. </P>
  65. <br><a name="SEC3" href="#TOC1">BRACED ITEMS</a><br>
  66. <P>
  67. With one exception, wherever brace characters { and } are required to enclose
  68. data for constructions such as \g{2} or \k{name}, space and/or horizontal tab
  69. characters that follow { or precede } are allowed and are ignored. In the case
  70. of quantifiers, they may also appear before or after the comma. The exception
  71. is \u{...} which is not Perl-compatible and is recognized only when
  72. PCRE2_EXTRA_ALT_BSUX is set. This is an ECMAScript compatibility feature, and
  73. follows ECMAScript's behaviour.
  74. </P>
  75. <br><a name="SEC4" href="#TOC1">ESCAPED CHARACTERS</a><br>
  76. <P>
  77. This table applies to ASCII and Unicode environments. An unrecognized escape
  78. sequence causes an error.
  79. <pre>
  80. \a alarm, that is, the BEL character (hex 07)
  81. \cx "control-x", where x is a non-control ASCII character
  82. \e escape (hex 1B)
  83. \f form feed (hex 0C)
  84. \n newline (hex 0A)
  85. \r carriage return (hex 0D)
  86. \t tab (hex 09)
  87. \0dd character with octal code 0dd
  88. \ddd character with octal code ddd, or backreference
  89. \o{ddd..} character with octal code ddd..
  90. \N{U+hh..} character with Unicode code point hh.. (Unicode mode only)
  91. \xhh character with hex code hh
  92. \x{hh..} character with hex code hh..
  93. </pre>
  94. If PCRE2_ALT_BSUX or PCRE2_EXTRA_ALT_BSUX is set ("ALT_BSUX mode"), the
  95. following are also recognized:
  96. <pre>
  97. \U the character "U"
  98. \uhhhh character with hex code hhhh
  99. \u{hh..} character with hex code hh.. but only for EXTRA_ALT_BSUX
  100. </pre>
  101. When \x is not followed by {, from zero to two hexadecimal digits are read,
  102. but in ALT_BSUX mode \x must be followed by two hexadecimal digits to be
  103. recognized as a hexadecimal escape; otherwise it matches a literal "x".
  104. Likewise, if \u (in ALT_BSUX mode) is not followed by four hexadecimal digits
  105. or (in EXTRA_ALT_BSUX mode) a sequence of hex digits in curly brackets, it
  106. matches a literal "u".
  107. </P>
  108. <P>
  109. Note that \0dd is always an octal code. The treatment of backslash followed by
  110. a non-zero digit is complicated; for details see the section
  111. <a href="pcre2pattern.html#digitsafterbackslash">"Non-printing characters"</a>
  112. in the
  113. <a href="pcre2pattern.html"><b>pcre2pattern</b></a>
  114. documentation, where details of escape processing in EBCDIC environments are
  115. also given. \N{U+hh..} is synonymous with \x{hh..} in PCRE2 but is not
  116. supported in EBCDIC environments. Note that \N not followed by an opening
  117. curly bracket has a different meaning (see below).
  118. </P>
  119. <br><a name="SEC5" href="#TOC1">CHARACTER TYPES</a><br>
  120. <P>
  121. <pre>
  122. . any character except newline;
  123. in dotall mode, any character whatsoever
  124. \C one code unit, even in UTF mode (best avoided)
  125. \d a decimal digit
  126. \D a character that is not a decimal digit
  127. \h a horizontal white space character
  128. \H a character that is not a horizontal white space character
  129. \N a character that is not a newline
  130. \p{<i>xx</i>} a character with the <i>xx</i> property
  131. \P{<i>xx</i>} a character without the <i>xx</i> property
  132. \R a newline sequence
  133. \s a white space character
  134. \S a character that is not a white space character
  135. \v a vertical white space character
  136. \V a character that is not a vertical white space character
  137. \w a "word" character
  138. \W a "non-word" character
  139. \X a Unicode extended grapheme cluster
  140. </pre>
  141. \C is dangerous because it may leave the current matching point in the middle
  142. of a UTF-8 or UTF-16 character. The application can lock out the use of \C by
  143. setting the PCRE2_NEVER_BACKSLASH_C option. It is also possible to build PCRE2
  144. with the use of \C permanently disabled.
  145. </P>
  146. <P>
  147. By default, \d, \s, and \w match only ASCII characters, even in UTF-8 mode
  148. or in the 16-bit and 32-bit libraries. However, if locale-specific matching is
  149. happening, \s and \w may also match characters with code points in the range
  150. 128-255. If the PCRE2_UCP option is set, the behaviour of these escape
  151. sequences is changed to use Unicode properties and they match many more
  152. characters, but there are some option settings that can restrict individual
  153. sequences to matching only ASCII characters.
  154. </P>
  155. <P>
  156. Property descriptions in \p and \P are matched caselessly; hyphens,
  157. underscores, and white space are ignored, in accordance with Unicode's "loose
  158. matching" rules.
  159. </P>
  160. <br><a name="SEC6" href="#TOC1">GENERAL CATEGORY PROPERTIES FOR \p and \P</a><br>
  161. <P>
  162. <pre>
  163. C Other
  164. Cc Control
  165. Cf Format
  166. Cn Unassigned
  167. Co Private use
  168. Cs Surrogate
  169. L Letter
  170. Ll Lower case letter
  171. Lm Modifier letter
  172. Lo Other letter
  173. Lt Title case letter
  174. Lu Upper case letter
  175. Lc Ll, Lu, or Lt
  176. L& Ll, Lu, or Lt
  177. M Mark
  178. Mc Spacing mark
  179. Me Enclosing mark
  180. Mn Non-spacing mark
  181. N Number
  182. Nd Decimal number
  183. Nl Letter number
  184. No Other number
  185. P Punctuation
  186. Pc Connector punctuation
  187. Pd Dash punctuation
  188. Pe Close punctuation
  189. Pf Final punctuation
  190. Pi Initial punctuation
  191. Po Other punctuation
  192. Ps Open punctuation
  193. S Symbol
  194. Sc Currency symbol
  195. Sk Modifier symbol
  196. Sm Mathematical symbol
  197. So Other symbol
  198. Z Separator
  199. Zl Line separator
  200. Zp Paragraph separator
  201. Zs Space separator
  202. </PRE>
  203. </P>
  204. <br><a name="SEC7" href="#TOC1">PCRE2 SPECIAL CATEGORY PROPERTIES FOR \p and \P</a><br>
  205. <P>
  206. <pre>
  207. Xan Alphanumeric: union of properties L and N
  208. Xps POSIX space: property Z or tab, NL, VT, FF, CR
  209. Xsp Perl space: property Z or tab, NL, VT, FF, CR
  210. Xuc Universally-named character: one that can be
  211. represented by a Universal Character Name
  212. Xwd Perl word: property Xan or underscore
  213. </pre>
  214. Perl and POSIX space are now the same. Perl added VT to its space character set
  215. at release 5.18.
  216. </P>
  217. <br><a name="SEC8" href="#TOC1">BINARY PROPERTIES FOR \p AND \P</a><br>
  218. <P>
  219. Unicode defines a number of binary properties, that is, properties whose only
  220. values are true or false. You can obtain a list of those that are recognized by
  221. \p and \P, along with their abbreviations, by running this command:
  222. <pre>
  223. pcre2test -LP
  224. </PRE>
  225. </P>
  226. <br><a name="SEC9" href="#TOC1">SCRIPT MATCHING WITH \p AND \P</a><br>
  227. <P>
  228. Many script names and their 4-letter abbreviations are recognized in
  229. \p{sc:...} or \p{scx:...} items, or on their own with \p (and also \P of
  230. course). You can obtain a list of these scripts by running this command:
  231. <pre>
  232. pcre2test -LS
  233. </PRE>
  234. </P>
  235. <br><a name="SEC10" href="#TOC1">THE BIDI_CLASS PROPERTY FOR \p AND \P</a><br>
  236. <P>
  237. <pre>
  238. \p{Bidi_Class:&#60;class&#62;} matches a character with the given class
  239. \p{BC:&#60;class&#62;} matches a character with the given class
  240. </pre>
  241. The recognized classes are:
  242. <pre>
  243. AL Arabic letter
  244. AN Arabic number
  245. B paragraph separator
  246. BN boundary neutral
  247. CS common separator
  248. EN European number
  249. ES European separator
  250. ET European terminator
  251. FSI first strong isolate
  252. L left-to-right
  253. LRE left-to-right embedding
  254. LRI left-to-right isolate
  255. LRO left-to-right override
  256. NSM non-spacing mark
  257. ON other neutral
  258. PDF pop directional format
  259. PDI pop directional isolate
  260. R right-to-left
  261. RLE right-to-left embedding
  262. RLI right-to-left isolate
  263. RLO right-to-left override
  264. S segment separator
  265. WS which space
  266. </PRE>
  267. </P>
  268. <br><a name="SEC11" href="#TOC1">CHARACTER CLASSES</a><br>
  269. <P>
  270. <pre>
  271. [...] positive character class
  272. [^...] negative character class
  273. [x-y] range (can be used for hex characters)
  274. [[:xxx:]] positive POSIX named set
  275. [[:^xxx:]] negative POSIX named set
  276. alnum alphanumeric
  277. alpha alphabetic
  278. ascii 0-127
  279. blank space or tab
  280. cntrl control character
  281. digit decimal digit
  282. graph printing, excluding space
  283. lower lower case letter
  284. print printing, including space
  285. punct printing, excluding alphanumeric
  286. space white space
  287. upper upper case letter
  288. word same as \w
  289. xdigit hexadecimal digit
  290. </pre>
  291. In PCRE2, POSIX character set names recognize only ASCII characters by default,
  292. but some of them use Unicode properties if PCRE2_UCP is set. You can use
  293. \Q...\E inside a character class.
  294. </P>
  295. <br><a name="SEC12" href="#TOC1">QUANTIFIERS</a><br>
  296. <P>
  297. <pre>
  298. ? 0 or 1, greedy
  299. ?+ 0 or 1, possessive
  300. ?? 0 or 1, lazy
  301. * 0 or more, greedy
  302. *+ 0 or more, possessive
  303. *? 0 or more, lazy
  304. + 1 or more, greedy
  305. ++ 1 or more, possessive
  306. +? 1 or more, lazy
  307. {n} exactly n
  308. {n,m} at least n, no more than m, greedy
  309. {n,m}+ at least n, no more than m, possessive
  310. {n,m}? at least n, no more than m, lazy
  311. {n,} n or more, greedy
  312. {n,}+ n or more, possessive
  313. {n,}? n or more, lazy
  314. {,m} zero up to m, greedy
  315. {,m}+ zero up to m, possessive
  316. {,m}? zero up to m, lazy
  317. </PRE>
  318. </P>
  319. <br><a name="SEC13" href="#TOC1">ANCHORS AND SIMPLE ASSERTIONS</a><br>
  320. <P>
  321. <pre>
  322. \b word boundary
  323. \B not a word boundary
  324. ^ start of subject
  325. also after an internal newline in multiline mode
  326. (after any newline if PCRE2_ALT_CIRCUMFLEX is set)
  327. \A start of subject
  328. $ end of subject
  329. also before newline at end of subject
  330. also before internal newline in multiline mode
  331. \Z end of subject
  332. also before newline at end of subject
  333. \z end of subject
  334. \G first matching position in subject
  335. </PRE>
  336. </P>
  337. <br><a name="SEC14" href="#TOC1">REPORTED MATCH POINT SETTING</a><br>
  338. <P>
  339. <pre>
  340. \K set reported start of match
  341. </pre>
  342. From release 10.38 \K is not permitted by default in lookaround assertions,
  343. for compatibility with Perl. However, if the PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK
  344. option is set, the previous behaviour is re-enabled. When this option is set,
  345. \K is honoured in positive assertions, but ignored in negative ones.
  346. </P>
  347. <br><a name="SEC15" href="#TOC1">ALTERNATION</a><br>
  348. <P>
  349. <pre>
  350. expr|expr|expr...
  351. </PRE>
  352. </P>
  353. <br><a name="SEC16" href="#TOC1">CAPTURING</a><br>
  354. <P>
  355. <pre>
  356. (...) capture group
  357. (?&#60;name&#62;...) named capture group (Perl)
  358. (?'name'...) named capture group (Perl)
  359. (?P&#60;name&#62;...) named capture group (Python)
  360. (?:...) non-capture group
  361. (?|...) non-capture group; reset group numbers for
  362. capture groups in each alternative
  363. </pre>
  364. In non-UTF modes, names may contain underscores and ASCII letters and digits;
  365. in UTF modes, any Unicode letters and Unicode decimal digits are permitted. In
  366. both cases, a name must not start with a digit.
  367. </P>
  368. <br><a name="SEC17" href="#TOC1">ATOMIC GROUPS</a><br>
  369. <P>
  370. <pre>
  371. (?&#62;...) atomic non-capture group
  372. (*atomic:...) atomic non-capture group
  373. </PRE>
  374. </P>
  375. <br><a name="SEC18" href="#TOC1">COMMENT</a><br>
  376. <P>
  377. <pre>
  378. (?#....) comment (not nestable)
  379. </PRE>
  380. </P>
  381. <br><a name="SEC19" href="#TOC1">OPTION SETTING</a><br>
  382. <P>
  383. Changes of these options within a group are automatically cancelled at the end
  384. of the group.
  385. <pre>
  386. (?a) all ASCII options
  387. (?aD) restrict \d to ASCII in UCP mode
  388. (?aS) restrict \s to ASCII in UCP mode
  389. (?aW) restrict \w to ASCII in UCP mode
  390. (?aP) restrict all POSIX classes to ASCII in UCP mode
  391. (?aT) restrict POSIX digit classes to ASCII in UCP mode
  392. (?i) caseless
  393. (?J) allow duplicate named groups
  394. (?m) multiline
  395. (?n) no auto capture
  396. (?r) restrict caseless to either ASCII or non-ASCII
  397. (?s) single line (dotall)
  398. (?U) default ungreedy (lazy)
  399. (?x) ignore white space except in classes or \Q...\E
  400. (?xx) as (?x) but also ignore space and tab in classes
  401. (?-...) unset the given option(s)
  402. (?^) unset imnrsx options
  403. </pre>
  404. (?aP) implies (?aT) as well, though this has no additional effect. However, it
  405. means that (?-aP) is really (?-PT) which disables all ASCII restrictions for
  406. POSIX classes.
  407. </P>
  408. <P>
  409. Unsetting x or xx unsets both. Several options may be set at once, and a
  410. mixture of setting and unsetting such as (?i-x) is allowed, but there may be
  411. only one hyphen. Setting (but no unsetting) is allowed after (?^ for example
  412. (?^in). An option setting may appear at the start of a non-capture group, for
  413. example (?i:...).
  414. </P>
  415. <P>
  416. The following are recognized only at the very start of a pattern or after one
  417. of the newline or \R options with similar syntax. More than one of them may
  418. appear. For the first three, d is a decimal number.
  419. <pre>
  420. (*LIMIT_DEPTH=d) set the backtracking limit to d
  421. (*LIMIT_HEAP=d) set the heap size limit to d * 1024 bytes
  422. (*LIMIT_MATCH=d) set the match limit to d
  423. (*NOTEMPTY) set PCRE2_NOTEMPTY when matching
  424. (*NOTEMPTY_ATSTART) set PCRE2_NOTEMPTY_ATSTART when matching
  425. (*NO_AUTO_POSSESS) no auto-possessification (PCRE2_NO_AUTO_POSSESS)
  426. (*NO_DOTSTAR_ANCHOR) no .* anchoring (PCRE2_NO_DOTSTAR_ANCHOR)
  427. (*NO_JIT) disable JIT optimization
  428. (*NO_START_OPT) no start-match optimization (PCRE2_NO_START_OPTIMIZE)
  429. (*UTF) set appropriate UTF mode for the library in use
  430. (*UCP) set PCRE2_UCP (use Unicode properties for \d etc)
  431. </pre>
  432. Note that LIMIT_DEPTH, LIMIT_HEAP, and LIMIT_MATCH can only reduce the value of
  433. the limits set by the caller of <b>pcre2_match()</b> or <b>pcre2_dfa_match()</b>,
  434. not increase them. LIMIT_RECURSION is an obsolete synonym for LIMIT_DEPTH. The
  435. application can lock out the use of (*UTF) and (*UCP) by setting the
  436. PCRE2_NEVER_UTF or PCRE2_NEVER_UCP options, respectively, at compile time.
  437. </P>
  438. <br><a name="SEC20" href="#TOC1">NEWLINE CONVENTION</a><br>
  439. <P>
  440. These are recognized only at the very start of the pattern or after option
  441. settings with a similar syntax.
  442. <pre>
  443. (*CR) carriage return only
  444. (*LF) linefeed only
  445. (*CRLF) carriage return followed by linefeed
  446. (*ANYCRLF) all three of the above
  447. (*ANY) any Unicode newline sequence
  448. (*NUL) the NUL character (binary zero)
  449. </PRE>
  450. </P>
  451. <br><a name="SEC21" href="#TOC1">WHAT \R MATCHES</a><br>
  452. <P>
  453. These are recognized only at the very start of the pattern or after option
  454. setting with a similar syntax.
  455. <pre>
  456. (*BSR_ANYCRLF) CR, LF, or CRLF
  457. (*BSR_UNICODE) any Unicode newline sequence
  458. </PRE>
  459. </P>
  460. <br><a name="SEC22" href="#TOC1">LOOKAHEAD AND LOOKBEHIND ASSERTIONS</a><br>
  461. <P>
  462. <pre>
  463. (?=...) )
  464. (*pla:...) ) positive lookahead
  465. (*positive_lookahead:...) )
  466. (?!...) )
  467. (*nla:...) ) negative lookahead
  468. (*negative_lookahead:...) )
  469. (?&#60;=...) )
  470. (*plb:...) ) positive lookbehind
  471. (*positive_lookbehind:...) )
  472. (?&#60;!...) )
  473. (*nlb:...) ) negative lookbehind
  474. (*negative_lookbehind:...) )
  475. </pre>
  476. Each top-level branch of a lookbehind must have a limit for the number of
  477. characters it matches. If any branch can match a variable number of characters,
  478. the maximum for each branch is limited to a value set by the caller of
  479. <b>pcre2_compile()</b> or defaulted. The default is set when PCRE2 is built
  480. (ultimate default 255). If every branch matches a fixed number of characters,
  481. the limit for each branch is 65535 characters.
  482. </P>
  483. <br><a name="SEC23" href="#TOC1">NON-ATOMIC LOOKAROUND ASSERTIONS</a><br>
  484. <P>
  485. These assertions are specific to PCRE2 and are not Perl-compatible.
  486. <pre>
  487. (?*...) )
  488. (*napla:...) ) synonyms
  489. (*non_atomic_positive_lookahead:...) )
  490. (?&#60;*...) )
  491. (*naplb:...) ) synonyms
  492. (*non_atomic_positive_lookbehind:...) )
  493. </PRE>
  494. </P>
  495. <br><a name="SEC24" href="#TOC1">SCRIPT RUNS</a><br>
  496. <P>
  497. <pre>
  498. (*script_run:...) ) script run, can be backtracked into
  499. (*sr:...) )
  500. (*atomic_script_run:...) ) atomic script run
  501. (*asr:...) )
  502. </PRE>
  503. </P>
  504. <br><a name="SEC25" href="#TOC1">BACKREFERENCES</a><br>
  505. <P>
  506. <pre>
  507. \n reference by number (can be ambiguous)
  508. \gn reference by number
  509. \g{n} reference by number
  510. \g+n relative reference by number (PCRE2 extension)
  511. \g-n relative reference by number
  512. \g{+n} relative reference by number (PCRE2 extension)
  513. \g{-n} relative reference by number
  514. \k&#60;name&#62; reference by name (Perl)
  515. \k'name' reference by name (Perl)
  516. \g{name} reference by name (Perl)
  517. \k{name} reference by name (.NET)
  518. (?P=name) reference by name (Python)
  519. </PRE>
  520. </P>
  521. <br><a name="SEC26" href="#TOC1">SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)</a><br>
  522. <P>
  523. <pre>
  524. (?R) recurse whole pattern
  525. (?n) call subroutine by absolute number
  526. (?+n) call subroutine by relative number
  527. (?-n) call subroutine by relative number
  528. (?&name) call subroutine by name (Perl)
  529. (?P&#62;name) call subroutine by name (Python)
  530. \g&#60;name&#62; call subroutine by name (Oniguruma)
  531. \g'name' call subroutine by name (Oniguruma)
  532. \g&#60;n&#62; call subroutine by absolute number (Oniguruma)
  533. \g'n' call subroutine by absolute number (Oniguruma)
  534. \g&#60;+n&#62; call subroutine by relative number (PCRE2 extension)
  535. \g'+n' call subroutine by relative number (PCRE2 extension)
  536. \g&#60;-n&#62; call subroutine by relative number (PCRE2 extension)
  537. \g'-n' call subroutine by relative number (PCRE2 extension)
  538. </PRE>
  539. </P>
  540. <br><a name="SEC27" href="#TOC1">CONDITIONAL PATTERNS</a><br>
  541. <P>
  542. <pre>
  543. (?(condition)yes-pattern)
  544. (?(condition)yes-pattern|no-pattern)
  545. (?(n) absolute reference condition
  546. (?(+n) relative reference condition (PCRE2 extension)
  547. (?(-n) relative reference condition (PCRE2 extension)
  548. (?(&#60;name&#62;) named reference condition (Perl)
  549. (?('name') named reference condition (Perl)
  550. (?(name) named reference condition (PCRE2, deprecated)
  551. (?(R) overall recursion condition
  552. (?(Rn) specific numbered group recursion condition
  553. (?(R&name) specific named group recursion condition
  554. (?(DEFINE) define groups for reference
  555. (?(VERSION[&#62;]=n.m) test PCRE2 version
  556. (?(assert) assertion condition
  557. </pre>
  558. Note the ambiguity of (?(R) and (?(Rn) which might be named reference
  559. conditions or recursion tests. Such a condition is interpreted as a reference
  560. condition if the relevant named group exists.
  561. </P>
  562. <br><a name="SEC28" href="#TOC1">BACKTRACKING CONTROL</a><br>
  563. <P>
  564. All backtracking control verbs may be in the form (*VERB:NAME). For (*MARK) the
  565. name is mandatory, for the others it is optional. (*SKIP) changes its behaviour
  566. if :NAME is present. The others just set a name for passing back to the caller,
  567. but this is not a name that (*SKIP) can see. The following act immediately they
  568. are reached:
  569. <pre>
  570. (*ACCEPT) force successful match
  571. (*FAIL) force backtrack; synonym (*F)
  572. (*MARK:NAME) set name to be passed back; synonym (*:NAME)
  573. </pre>
  574. The following act only when a subsequent match failure causes a backtrack to
  575. reach them. They all force a match failure, but they differ in what happens
  576. afterwards. Those that advance the start-of-match point do so only if the
  577. pattern is not anchored.
  578. <pre>
  579. (*COMMIT) overall failure, no advance of starting point
  580. (*PRUNE) advance to next starting character
  581. (*SKIP) advance to current matching position
  582. (*SKIP:NAME) advance to position corresponding to an earlier
  583. (*MARK:NAME); if not found, the (*SKIP) is ignored
  584. (*THEN) local failure, backtrack to next alternation
  585. </pre>
  586. The effect of one of these verbs in a group called as a subroutine is confined
  587. to the subroutine call.
  588. </P>
  589. <br><a name="SEC29" href="#TOC1">CALLOUTS</a><br>
  590. <P>
  591. <pre>
  592. (?C) callout (assumed number 0)
  593. (?Cn) callout with numerical data n
  594. (?C"text") callout with string data
  595. </pre>
  596. The allowed string delimiters are ` ' " ^ % # $ (which are the same for the
  597. start and the end), and the starting delimiter { matched with the ending
  598. delimiter }. To encode the ending delimiter within the string, double it.
  599. </P>
  600. <br><a name="SEC30" href="#TOC1">SEE ALSO</a><br>
  601. <P>
  602. <b>pcre2pattern</b>(3), <b>pcre2api</b>(3), <b>pcre2callout</b>(3),
  603. <b>pcre2matching</b>(3), <b>pcre2</b>(3).
  604. </P>
  605. <br><a name="SEC31" href="#TOC1">AUTHOR</a><br>
  606. <P>
  607. Philip Hazel
  608. <br>
  609. Retired from University Computing Service
  610. <br>
  611. Cambridge, England.
  612. <br>
  613. </P>
  614. <br><a name="SEC32" href="#TOC1">REVISION</a><br>
  615. <P>
  616. Last updated: 12 October 2023
  617. <br>
  618. Copyright &copy; 1997-2023 University of Cambridge.
  619. <br>
  620. <p>
  621. Return to the <a href="index.html">PCRE2 index page</a>.
  622. </p>