---
name: "pcre2_pattern_info"
section: "3"
platform: "linux"
package: "pcre2"
version: "10.49-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pcre2_pattern_info"
---

# pcre2\_pattern\_info(3)

Perl-compatible regular expressions (revised API)

## NAME

PCRE2 - Perl-compatible regular expressions (revised API)

## SYNOPSIS

**#include \<pcre2.h\>**

```
int pcre2_pattern_info(const pcre2_code *code, uint32_t what,
   void *where);
```

## DESCRIPTION

This function returns information about a compiled pattern. Its arguments are:

  *code*     Pointer to a compiled regular expression pattern\
   *what*     What information is required\
   *where*    Where to put the information

The recognized values for the *what* argument, and the information they request are as follows:

  PCRE2\_INFO\_ALLOPTIONS      Final options after compiling\
   PCRE2\_INFO\_ARGOPTIONS      Options passed to **pcre2\_compile()**\
   PCRE2\_INFO\_BACKREFMAX      Number of highest backreference\
   PCRE2\_INFO\_BSR             What \\R matches:\
                                PCRE2\_BSR\_UNICODE: Unicode line endings\
                                PCRE2\_BSR\_ANYCRLF: CR, LF, or CRLF only\
   PCRE2\_INFO\_CAPTURECOUNT    Number of capturing subpatterns\
   PCRE2\_INFO\_DEPTHLIMIT      Backtracking depth limit if set,\
                                otherwise PCRE2\_ERROR\_UNSET\
   PCRE2\_INFO\_EXTRAOPTIONS    Extra options that were passed in the\
                                compile context\
   PCRE2\_INFO\_FIRSTBITMAP     Bitmap of first code units, or NULL\
   PCRE2\_INFO\_FIRSTCODETYPE   Type of start-of-match information\
                                0 nothing set\
                                1 first code unit is set\
                                2 start of string or after newline\
   PCRE2\_INFO\_FIRSTCODEUNIT   First code unit when type is 1\
   PCRE2\_INFO\_FRAMESIZE       Size of backtracking frame\
   PCRE2\_INFO\_HASBACKSLASHC   Return 1 if pattern contains \\C\
   PCRE2\_INFO\_HASCRORLF       Return 1 if explicit CR or LF matches\
                                exist in the pattern\
   PCRE2\_INFO\_HEAPLIMIT       Heap memory limit if set,\
                                otherwise PCRE2\_ERROR\_UNSET\
   PCRE2\_INFO\_JCHANGED        Return 1 if (?J) or (?-J) was used\
   PCRE2\_INFO\_JITSIZE         Size of JIT compiled code, or 0\
   PCRE2\_INFO\_LASTCODETYPE    Type of must-be-present information\
                                0 nothing set\
                                1 code unit is set\
   PCRE2\_INFO\_LASTCODEUNIT    Last code unit when type is 1\
   PCRE2\_INFO\_MATCHEMPTY      1 if the pattern can match an\
                                empty string, 0 otherwise\
   PCRE2\_INFO\_MATCHLIMIT      Match limit if set,\
                                otherwise PCRE2\_ERROR\_UNSET\
   PCRE2\_INFO\_MAXLOOKBEHIND   Length (in characters) of the longest\
                                lookbehind assertion\
   PCRE2\_INFO\_MINLENGTH       Lower bound length of matching strings\
   PCRE2\_INFO\_NAMECOUNT       Number of named subpatterns\
   PCRE2\_INFO\_NAMEENTRYSIZE   Size of name table entries\
   PCRE2\_INFO\_NAMETABLE       Pointer to name table\
   PCRE2\_CONFIG\_NEWLINE       Code for the newline sequence:\
                                PCRE2\_NEWLINE\_CR\
                                PCRE2\_NEWLINE\_LF\
                                PCRE2\_NEWLINE\_CRLF\
                                PCRE2\_NEWLINE\_ANY\
                                PCRE2\_NEWLINE\_ANYCRLF\
                                PCRE2\_NEWLINE\_NUL\
   PCRE2\_INFO\_RECURSIONLIMIT  Obsolete synonym for PCRE2\_INFO\_DEPTHLIMIT\
   PCRE2\_INFO\_SIZE            Size of compiled pattern

If *where* is NULL, the function returns the amount of memory needed for the requested information, in bytes. Otherwise, the *where* argument must point to an unsigned 32-bit integer (uint32\_t variable), except for the following *what* values, when it must point to a variable of the type shown:

  PCRE2\_INFO\_FIRSTBITMAP     const uint8\_t \*\
   PCRE2\_INFO\_JITSIZE         size\_t\
   PCRE2\_INFO\_NAMETABLE       PCRE2\_SPTR\
   PCRE2\_INFO\_SIZE            size\_t

The yield of the function is zero on success or:

  PCRE2\_ERROR\_NULL           the argument *code* is NULL\
   PCRE2\_ERROR\_BADMAGIC       the "magic number" was not found\
   PCRE2\_ERROR\_BADOPTION      the value of *what* is invalid\
   PCRE2\_ERROR\_BADMODE        the pattern was compiled in the wrong mode\
   PCRE2\_ERROR\_UNSET          the requested information is not set

There is a complete description of the PCRE2 native API in the **pcre2api** page and a description of the POSIX API in the **pcre2posix** page.
