chiark / gitweb /
pcre3 (1:8.30-5) unstable; urgency=low
[pcre3.git] / doc / pcre_exec.3
1 .TH PCRE_EXEC 3
2 .SH NAME
3 PCRE - Perl-compatible regular expressions
4 .SH SYNOPSIS
5 .rs
6 .sp
7 .B #include <pcre.h>
8 .PP
9 .SM
10 .B int pcre_exec(const pcre *\fIcode\fP, "const pcre_extra *\fIextra\fP,"
11 .ti +5n
12 .B "const char *\fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
13 .ti +5n
14 .B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);
15 .PP
16 .B int pcre16_exec(const pcre16 *\fIcode\fP, "const pcre16_extra *\fIextra\fP,"
17 .ti +5n
18 .B "PCRE_SPTR16 \fIsubject\fP," int \fIlength\fP, int \fIstartoffset\fP,
19 .ti +5n
20 .B int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);
21 .
22 .SH DESCRIPTION
23 .rs
24 .sp
25 This function matches a compiled regular expression against a given subject
26 string, using a matching algorithm that is similar to Perl's. It returns
27 offsets to captured substrings. Its arguments are:
28 .sp
29   \fIcode\fP         Points to the compiled pattern
30   \fIextra\fP        Points to an associated \fBpcre[16]_extra\fP structure,
31                  or is NULL
32   \fIsubject\fP      Points to the subject string
33   \fIlength\fP       Length of the subject string, in bytes
34   \fIstartoffset\fP  Offset in bytes in the subject at which to
35                  start matching
36   \fIoptions\fP      Option bits
37   \fIovector\fP      Points to a vector of ints for result offsets
38   \fIovecsize\fP     Number of elements in the vector (a multiple of 3)
39 .sp
40 The options are:
41 .sp
42   PCRE_ANCHORED          Match only at the first position
43   PCRE_BSR_ANYCRLF       \eR matches only CR, LF, or CRLF
44   PCRE_BSR_UNICODE       \eR matches all Unicode line endings
45   PCRE_NEWLINE_ANY       Recognize any Unicode newline sequence
46   PCRE_NEWLINE_ANYCRLF   Recognize CR, LF, & CRLF as newline sequences
47   PCRE_NEWLINE_CR        Recognize CR as the only newline sequence
48   PCRE_NEWLINE_CRLF      Recognize CRLF as the only newline sequence
49   PCRE_NEWLINE_LF        Recognize LF as the only newline sequence
50   PCRE_NOTBOL            Subject string is not the beginning of a line
51   PCRE_NOTEOL            Subject string is not the end of a line
52   PCRE_NOTEMPTY          An empty string is not a valid match
53   PCRE_NOTEMPTY_ATSTART  An empty string at the start of the subject
54                            is not a valid match
55   PCRE_NO_START_OPTIMIZE Do not do "start-match" optimizations
56   PCRE_NO_UTF16_CHECK    Do not check the subject for UTF-16
57                            validity (only relevant if PCRE_UTF16
58                            was set at compile time)
59   PCRE_NO_UTF8_CHECK     Do not check the subject for UTF-8
60                            validity (only relevant if PCRE_UTF8
61                            was set at compile time)
62   PCRE_PARTIAL           ) Return PCRE_ERROR_PARTIAL for a partial
63   PCRE_PARTIAL_SOFT      )   match if no full matches are found
64   PCRE_PARTIAL_HARD      Return PCRE_ERROR_PARTIAL for a partial match
65                            if that is found before a full match
66 .sp
67 For details of partial matching, see the
68 .\" HREF
69 \fBpcrepartial\fP
70 .\"
71 page. A \fBpcre_extra\fP structure contains the following fields:
72 .sp
73   \fIflags\fP            Bits indicating which fields are set
74   \fIstudy_data\fP       Opaque data from \fBpcre[16]_study()\fP
75   \fImatch_limit\fP      Limit on internal resource use
76   \fImatch_limit_recursion\fP  Limit on internal recursion depth
77   \fIcallout_data\fP     Opaque data passed back to callouts
78   \fItables\fP           Points to character tables or is NULL
79   \fImark\fP             For passing back a *MARK pointer
80   \fIexecutable_jit\fP   Opaque data from JIT compilation
81 .sp
82 The flag bits are PCRE_EXTRA_STUDY_DATA, PCRE_EXTRA_MATCH_LIMIT,
83 PCRE_EXTRA_MATCH_LIMIT_RECURSION, PCRE_EXTRA_CALLOUT_DATA,
84 PCRE_EXTRA_TABLES, PCRE_EXTRA_MARK and PCRE_EXTRA_EXECUTABLE_JIT.
85 .P
86 There is a complete description of the PCRE native API in the
87 .\" HREF
88 \fBpcreapi\fP
89 .\"
90 page and a description of the POSIX API in the
91 .\" HREF
92 \fBpcreposix\fP
93 .\"
94 page.