blob: edd8989d9e185495e53e6771ad7414d60512e76f [file] [log] [blame]
Elliott Hughes0c26e192019-08-07 12:24:46 -07001.TH PCRE2_PATTERN_INFO 3 "14 February 2019" "PCRE2 10.33"
Janis Danisevskis112c9cc2016-03-31 13:35:25 +01002.SH NAME
3PCRE2 - Perl-compatible regular expressions (revised API)
4.SH SYNOPSIS
5.rs
6.sp
7.B #include <pcre2.h>
8.PP
9.nf
Elliott Hughes0c26e192019-08-07 12:24:46 -070010.B int pcre2_pattern_info(const pcre2_code *\fIcode\fP, uint32_t \fIwhat\fP,
11.B " void *\fIwhere\fP);"
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010012.fi
13.
14.SH DESCRIPTION
15.rs
16.sp
17This function returns information about a compiled pattern. Its arguments are:
18.sp
Elliott Hughes9bc971b2018-07-27 13:23:14 -070019 \fIcode\fP Pointer to a compiled regular expression pattern
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010020 \fIwhat\fP What information is required
21 \fIwhere\fP Where to put the information
22.sp
23The recognized values for the \fIwhat\fP argument, and the information they
24request are as follows:
25.sp
26 PCRE2_INFO_ALLOPTIONS Final options after compiling
27 PCRE2_INFO_ARGOPTIONS Options passed to \fBpcre2_compile()\fP
Elliott Hughes653c2102019-01-09 15:41:36 -080028 PCRE2_INFO_BACKREFMAX Number of highest backreference
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010029 PCRE2_INFO_BSR What \eR matches:
30 PCRE2_BSR_UNICODE: Unicode line endings
31 PCRE2_BSR_ANYCRLF: CR, LF, or CRLF only
32 PCRE2_INFO_CAPTURECOUNT Number of capturing subpatterns
Elliott Hughes9bc971b2018-07-27 13:23:14 -070033.\" JOIN
34 PCRE2_INFO_DEPTHLIMIT Backtracking depth limit if set,
35 otherwise PCRE2_ERROR_UNSET
36 PCRE2_INFO_EXTRAOPTIONS Extra options that were passed in the
37 compile context
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010038 PCRE2_INFO_FIRSTBITMAP Bitmap of first code units, or NULL
39 PCRE2_INFO_FIRSTCODETYPE Type of start-of-match information
40 0 nothing set
41 1 first code unit is set
42 2 start of string or after newline
43 PCRE2_INFO_FIRSTCODEUNIT First code unit when type is 1
Elliott Hughes9bc971b2018-07-27 13:23:14 -070044 PCRE2_INFO_FRAMESIZE Size of backtracking frame
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010045 PCRE2_INFO_HASBACKSLASHC Return 1 if pattern contains \eC
Elliott Hughes9bc971b2018-07-27 13:23:14 -070046.\" JOIN
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010047 PCRE2_INFO_HASCRORLF Return 1 if explicit CR or LF matches
48 exist in the pattern
Elliott Hughes9bc971b2018-07-27 13:23:14 -070049.\" JOIN
50 PCRE2_INFO_HEAPLIMIT Heap memory limit if set,
51 otherwise PCRE2_ERROR_UNSET
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010052 PCRE2_INFO_JCHANGED Return 1 if (?J) or (?-J) was used
53 PCRE2_INFO_JITSIZE Size of JIT compiled code, or 0
54 PCRE2_INFO_LASTCODETYPE Type of must-be-present information
55 0 nothing set
56 1 code unit is set
57 PCRE2_INFO_LASTCODEUNIT Last code unit when type is 1
Elliott Hughes9bc971b2018-07-27 13:23:14 -070058.\" JOIN
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010059 PCRE2_INFO_MATCHEMPTY 1 if the pattern can match an
60 empty string, 0 otherwise
Elliott Hughes9bc971b2018-07-27 13:23:14 -070061.\" JOIN
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010062 PCRE2_INFO_MATCHLIMIT Match limit if set,
63 otherwise PCRE2_ERROR_UNSET
Elliott Hughes9bc971b2018-07-27 13:23:14 -070064.\" JOIN
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010065 PCRE2_INFO_MAXLOOKBEHIND Length (in characters) of the longest
66 lookbehind assertion
67 PCRE2_INFO_MINLENGTH Lower bound length of matching strings
68 PCRE2_INFO_NAMECOUNT Number of named subpatterns
69 PCRE2_INFO_NAMEENTRYSIZE Size of name table entries
70 PCRE2_INFO_NAMETABLE Pointer to name table
71 PCRE2_CONFIG_NEWLINE Code for the newline sequence:
72 PCRE2_NEWLINE_CR
73 PCRE2_NEWLINE_LF
74 PCRE2_NEWLINE_CRLF
75 PCRE2_NEWLINE_ANY
76 PCRE2_NEWLINE_ANYCRLF
Elliott Hughes9bc971b2018-07-27 13:23:14 -070077 PCRE2_NEWLINE_NUL
78 PCRE2_INFO_RECURSIONLIMIT Obsolete synonym for PCRE2_INFO_DEPTHLIMIT
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010079 PCRE2_INFO_SIZE Size of compiled pattern
80.sp
81If \fIwhere\fP is NULL, the function returns the amount of memory needed for
82the requested information, in bytes. Otherwise, the \fIwhere\fP argument must
83point to an unsigned 32-bit integer (uint32_t variable), except for the
84following \fIwhat\fP values, when it must point to a variable of the type
85shown:
86.sp
87 PCRE2_INFO_FIRSTBITMAP const uint8_t *
88 PCRE2_INFO_JITSIZE size_t
89 PCRE2_INFO_NAMETABLE PCRE2_SPTR
90 PCRE2_INFO_SIZE size_t
91.sp
92The yield of the function is zero on success or:
93.sp
94 PCRE2_ERROR_NULL the argument \fIcode\fP is NULL
95 PCRE2_ERROR_BADMAGIC the "magic number" was not found
96 PCRE2_ERROR_BADOPTION the value of \fIwhat\fP is invalid
97 PCRE2_ERROR_BADMODE the pattern was compiled in the wrong mode
98 PCRE2_ERROR_UNSET the requested information is not set
99.P
100There is a complete description of the PCRE2 native API in the
101.\" HREF
102\fBpcre2api\fP
103.\"
104page and a description of the POSIX API in the
105.\" HREF
106\fBpcre2posix\fP
107.\"
108page.