1PCRE2_MATCH(3) Library Functions Manual PCRE2_MATCH(3)
2
3
4
6 PCRE2 - Perl-compatible regular expressions (revised API)
7
9
10 #include <pcre2.h>
11
12 int pcre2_match(const pcre2_code *code, PCRE2_SPTR subject,
13 PCRE2_SIZE length, PCRE2_SIZE startoffset,
14 uint32_t options, pcre2_match_data *match_data,
15 pcre2_match_context *mcontext);
16
18
19 This function matches a compiled regular expression against a given
20 subject string, using a matching algorithm that is similar to Perl's.
21 It returns offsets to what it has matched and to captured substrings
22 via the match_data block, which can be processed by functions with
23 names that start with pcre2_get_ovector_...() or pcre2_substring_...().
24 The return from pcre2_match() is one more than the highest numbered
25 capturing pair that has been set (for example, 1 if there are no cap‐
26 tures), zero if the vector of offsets is too small, or a negative error
27 code for no match and other errors. The function arguments are:
28
29 code Points to the compiled pattern
30 subject Points to the subject string
31 length Length of the subject string
32 startoffset Offset in the subject at which to start matching
33 options Option bits
34 match_data Points to a match data block, for results
35 mcontext Points to a match context, or is NULL
36
37 A match context is needed only if you want to:
38
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
46 The length and startoffset values are code units, not characters. The
47 length may be given as PCRE2_ZERO_TERMINATE for a subject that is ter‐
48 minated by a binary zero code unit. The options are:
49
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 PCRE2_NOTEMPTY_ATSTART An empty string at the start of the subject
56 is not a valid match
57 PCRE2_NO_JIT Do not use JIT matching
58 PCRE2_NO_UTF_CHECK Do not check the subject for UTF
59 validity (only relevant if PCRE2_UTF
60 was set at compile time)
61 PCRE2_PARTIAL_HARD Return PCRE2_ERROR_PARTIAL for a partial
62 match even if there is a full match
63 PCRE2_PARTIAL_SOFT Return PCRE2_ERROR_PARTIAL for a partial
64 match if no full matches are found
65
66 For details of partial matching, see the pcre2partial page. There is a
67 complete description of the PCRE2 native API in the pcre2api page and a
68 description of the POSIX API in the pcre2posix page.
69
70
71
72PCRE2 10.31 14 November 2017 PCRE2_MATCH(3)