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

# pcre2\_set\_optimize(3)

Perl-compatible regular expressions (revised API)

## NAME

PCRE2 - Perl-compatible regular expressions (revised API)

## SYNOPSIS

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

```
int pcre2_set_optimize(pcre2_compile_context *ccontext,
  uint32_t directive);
```

## DESCRIPTION

This function controls which performance optimizations will be applied by **pcre2\_compile()**. It can be called multiple times with the same compile context; the effects are cumulative, with the effects of later calls taking precedence over earlier ones.

The result is zero for success, PCRE2\_ERROR\_NULL if *ccontext* is NULL, or PCRE2\_ERROR\_BADOPTION if *directive* is unknown. The latter could be useful to detect if a certain optimization is available.

The list of possible values for the *directive* parameter are:

  PCRE2\_OPTIMIZATION\_FULL   Enable all optimizations (default)\
   PCRE2\_OPTIMIZATION\_NONE   Disable all optimizations\
   PCRE2\_AUTO\_POSSESS        Enable auto-possessification\
   PCRE2\_AUTO\_POSSESS\_OFF    Disable auto-possessification\
   PCRE2\_DOTSTAR\_ANCHOR      Enable implicit dotstar anchoring\
   PCRE2\_DOTSTAR\_ANCHOR\_OFF  Disable implicit dotstar anchoring\
   PCRE2\_START\_OPTIMIZE      Enable start-up optimizations at match time\
   PCRE2\_START\_OPTIMIZE\_OFF  Disable start-up optimizations at match time

There is a complete description of the PCRE2 native API, including detailed descriptions *directive* parameter values in the **pcre2api** page.
