PCRE2_PATTERN_CONVERT(3)

πŸ’– PCRE2_PATTERN_CONVERT(3) πŸ’–

okay bestie, welcome to the Library Functions Manual page for PCRE2_PATTERN_CONVERT(3) β€” yes, the manual name is folded in right here instead of being a whole copied header line, we're cute like that πŸ’…. This one is about the pattern conversion function, and it's giving experimental energy (more on that in a sec).

✨ NAME ✨

PCRE2 - Perl-compatible regular expressions (revised API). πŸ’–

πŸ¦‹ SYNOPSIS πŸ¦‹

       #include <pcre2.h>

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

🌸 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. iconic.

πŸŽ€ Its arguments, bestie πŸŽ€

  • 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. ✨

πŸ’… Option bits πŸ’…

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
okay so the last three are grouped in the original with those ) markers β€” the full grouped bit reads Convert various types of glob. Not me lowkey loving that the manpage keeps its little ) grouping vibe intact 🫢. iykyk.

🌈 Return value 🌈

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.


xoxo, your Unix bestie 🫢 β€” that was PCRE2_PATTERN_CONVERT(3), from PCRE2 10.47, dated 12 July 2017. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from