PCRE2_JIT_MATCH(3)

πŸŽ€ NAME πŸŽ€

okay bestie, welcome to PCRE2_JIT_MATCH(3) from the Library Functions Manual πŸ’…βœ¨. The NAME section is giving:

PCRE2 - Perl-compatible regular expressions (revised API)

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <pcre2.h>

int pcre2_jit_match(const pcre2_code *code, PCRE2_SPTR subject,
  PCRE2_SIZE length, PCRE2_SIZE startoffset,
  uint32_t options, pcre2_match_data *match_data,
  pcre2_match_context *mcontext);

πŸ’– DESCRIPTION πŸ’–

okay so this function matches a compiled regular expression that has been successfully processed by the JIT compiler against a given subject string, using a matching algorithm that is similar to Perl's. It's a "fast path" interface to JIT, and it bypasses some of the sanity checks that pcre2_match() applies. slay for speed, but bestie, read the warnings πŸ‘€

⚠️ In UTF mode, the subject string is not checked for UTF validity. Unless PCRE2_MATCH_INVALID_UTF was set when the pattern was compiled, passing an invalid UTF string results in undefined behaviour. Your program may crash or loop or give wrong results. In the absence of PCRE2_MATCH_INVALID_UTF you should only call pcre2_jit_match() in UTF mode if you are sure the subject is valid. no cap, this is the serious bit 😭

The arguments for pcre2_jit_match() are exactly the same as for pcre2_match(), except that the subject string must be specified with a length; PCRE2_ZERO_TERMINATED is not supported. periodt.

The supported options are literally these six:

  • PCRE2_NOTBOL β€” supported ✨
  • PCRE2_NOTEOL β€” supported ✨
  • PCRE2_NOTEMPTY β€” supported ✨
  • PCRE2_NOTEMPTY_ATSTART β€” supported ✨
  • PCRE2_PARTIAL_HARD β€” supported ✨
  • PCRE2_PARTIAL_SOFT β€” supported ✨

Unsupported options are ignored. (not me having to say it, but okay 🫢)

The return values are the same as for pcre2_match() plus PCRE2_ERROR_JIT_BADOPTION if a matching mode (partial or complete) is requested that was not compiled. For details of partial matching, see the pcre2partial page.

There is a complete description of the PCRE2 native API in the pcre2api page and a description of the JIT API in the pcre2jit page. go read those if you want the full lore πŸ“šπŸ’…


mwah πŸ’‹ that's the whole page, signed off from PCRE2 10.47, dated 20 January 2023 β€” bye bestie, stay valid in UTF mode πŸ§šβ€β™€οΈπŸ’–

πŸ“¦ where this page comes from