new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / external / pcre2-10.32 / doc / pcre2_match.3
1 .TH PCRE2_MATCH 3 "14 November 2017" "PCRE2 10.31"
2 .SH NAME
3 PCRE2 - Perl-compatible regular expressions (revised API)
4 .SH SYNOPSIS
5 .rs
6 .sp
7 .B #include <pcre2.h>
8 .PP
9 .nf
10 .B int pcre2_match(const pcre2_code *\fIcode\fP, PCRE2_SPTR \fIsubject\fP,
11 .B "  PCRE2_SIZE \fIlength\fP, PCRE2_SIZE \fIstartoffset\fP,"
12 .B "  uint32_t \fIoptions\fP, pcre2_match_data *\fImatch_data\fP,"
13 .B "  pcre2_match_context *\fImcontext\fP);"
14 .fi
15 .
16 .SH DESCRIPTION
17 .rs
18 .sp
19 This function matches a compiled regular expression against a given subject
20 string, using a matching algorithm that is similar to Perl's. It returns
21 offsets to what it has matched and to captured substrings via the
22 \fBmatch_data\fP block, which can be processed by functions with names that
23 start with \fBpcre2_get_ovector_...()\fP or \fBpcre2_substring_...()\fP. The
24 return from \fBpcre2_match()\fP is one more than the highest numbered capturing
25 pair that has been set (for example, 1 if there are no captures), zero if the
26 vector of offsets is too small, or a negative error code for no match and other
27 errors. The function arguments are:
28 .sp
29   \fIcode\fP         Points to the compiled pattern
30   \fIsubject\fP      Points to the subject string
31   \fIlength\fP       Length of the subject string
32   \fIstartoffset\fP  Offset in the subject at which to start matching
33   \fIoptions\fP      Option bits
34   \fImatch_data\fP   Points to a match data block, for results
35   \fImcontext\fP     Points to a match context, or is NULL
36 .sp
37 A match context is needed only if you want to:
38 .sp
39   Set up a callout function
40   Set a matching offset limit
41   Change the heap memory limit
42   Change the backtracking match limit
43   Change the backtracking depth limit
44   Set custom memory management specifically for the match
45 .sp
46 The \fIlength\fP and \fIstartoffset\fP values are code
47 units, not characters. The length may be given as PCRE2_ZERO_TERMINATE for a
48 subject that is terminated by a binary zero code unit. The options are:
49 .sp
50   PCRE2_ANCHORED          Match only at the first position
51   PCRE2_ENDANCHORED       Pattern can match only at end of subject
52   PCRE2_NOTBOL            Subject string is not the beginning of a line
53   PCRE2_NOTEOL            Subject string is not the end of a line
54   PCRE2_NOTEMPTY          An empty string is not a valid match
55 .\" JOIN
56   PCRE2_NOTEMPTY_ATSTART  An empty string at the start of the subject
57                            is not a valid match
58   PCRE2_NO_JIT            Do not use JIT matching
59 .\" JOIN
60   PCRE2_NO_UTF_CHECK      Do not check the subject for UTF
61                            validity (only relevant if PCRE2_UTF
62                            was set at compile time)
63 .\" JOIN
64   PCRE2_PARTIAL_HARD      Return PCRE2_ERROR_PARTIAL for a partial
65                            match even if there is a full match
66 .\" JOIN
67   PCRE2_PARTIAL_SOFT      Return PCRE2_ERROR_PARTIAL for a partial
68                            match if no full matches are found
69 .sp
70 For details of partial matching, see the
71 .\" HREF
72 \fBpcre2partial\fP
73 .\"
74 page. There is a complete description of the PCRE2 native API in the
75 .\" HREF
76 \fBpcre2api\fP
77 .\"
78 page and a description of the POSIX API in the
79 .\" HREF
80 \fBpcre2posix\fP
81 .\"
82 page.