PCRE2\_PATTERN\_CONVERT(3) Library Functions Manual PCRE2\_PATTERN\_CONVERT(3)

# [NAME](#NAME)

PCRE2 - Perl-compatible regular expressions (revised API)

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;pcre2.h&gt;**

```
int pcre2_pattern_convert(PCRE2_SPTR pattern, PCRE2_SIZE length,
  uint32_t options, PCRE2_UCHAR **buffer,
  PCRE2_SIZE *blength, pcre2_convert_context *cvcontext);
```

# [DESCRIPTION](#DESCRIPTION)

This function is part of an experimental set of pattern conversion functions. It converts a foreign pattern (for example, a glob) into a PCRE2 regular expression pattern. Its arguments are:

*pattern* The foreign pattern  
*length* The length of the input pattern or PCRE2\_ZERO\_TERMINATED  
*options* Option bits  
*buffer* Pointer to pointer to output buffer, or NULL  
*blength* Pointer to output length field  
*cvcontext* Pointer to a convert context or NULL

The length of the converted pattern (excluding the terminating zero) is returned via *blength*. If *buffer* is NULL, the function just returns the output length. If *buffer* points to a NULL pointer, heap memory is obtained for the converted pattern, using the allocator in the context if present (or else **malloc()**), and the field pointed to by *buffer* is updated. If *buffer* points to a non-NULL field, that must point to a buffer whose size is in the variable pointed to by *blength*. This value is updated.

The option bits are:

PCRE2\_CONVERT\_UTF Input is UTF  
PCRE2\_CONVERT\_NO\_UTF\_CHECK Do not check UTF validity  
PCRE2\_CONVERT\_POSIX\_BASIC Convert POSIX basic pattern  
PCRE2\_CONVERT\_POSIX\_EXTENDED Convert POSIX extended pattern  
PCRE2\_CONVERT\_GLOB ) Convert  
PCRE2\_CONVERT\_GLOB\_NO\_WILD\_SEPARATOR ) various types  
PCRE2\_CONVERT\_GLOB\_NO\_STARSTAR ) of glob

The return value from **pcre2\_pattern\_convert()** is zero on success or a non-zero PCRE2 error code.

The pattern conversion functions are described in the **pcre2convert** documentation.

12 July 2017 PCRE2 10.49

---

Document: pcre2_pattern_convert(3) from pcre2 10.49-r1 (Chainguard OS)
Source: https://github.com/PCRE2Project/pcre2.git
