PCRE2_SET_NEWLINE(3)

🌸 NAME 🌸

PCRE2 β€” Perl-compatible regular expressions (revised API). This page is PCRE2_SET_NEWLINE(3) from the Library Functions Manual, and it's your little guide to telling PCRE2 what counts as a newline. Periodt. πŸ’…

✨ SYNOPSIS ✨

Okay bestie, here's the exact spell:

#include <pcre2.h>

int pcre2_set_newline(pcre2_compile_context *ccontext,
  uint32_t value);

πŸ’– DESCRIPTION πŸ’–

This function sets the newline convention within a compile context. Lowkey important: it tells PCRE2 which character(s) count as newlines when it compiles and matches patterns. It's giving β€œchoose your newline destiny,” and honestly? Obsessed. 🌈

The second argument value must be one of these iconic options, no cap:

  • PCRE2_NEWLINE_CR β€” Carriage return only πŸŽ€
  • PCRE2_NEWLINE_LF β€” Linefeed only ✨
  • PCRE2_NEWLINE_CRLF β€” CR followed by LF only πŸ’«
  • PCRE2_NEWLINE_ANYCRLF β€” Any of the above πŸ‘‘
  • PCRE2_NEWLINE_ANY β€” Any Unicode newline sequence πŸ¦‹
  • PCRE2_NEWLINE_NUL β€” The NUL character (binary zero) πŸ’€

The result is zero for success, or PCRE2_ERROR_BADDATA if the second argument is invalid. So yeah, bad value = instant vibe check fail, but at least the error code tells you what's up. 🫢

There's a complete description of the PCRE2 native API in the pcre2api page, and a description of the POSIX API in the pcre2posix page. Go read those if you want the full lore, iykyk. πŸ“š


Signed, sealed, and sent with sparkles by PCRE2 10.47, dated 19 July 2017. That's the PCRE2_SET_NEWLINE(3) page, bestie β€” now go set some newlines! πŸ§šπŸ’–

πŸ“¦ where this page comes from