std::regex_...ch_flag_type(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

std::regex_...ch_flag_type(3) πŸ’–

okay so this is the C++ Standard Libary page for std::regex_...ch_flag_type(3) β€” yes, the manual name spells β€œLibary” like that, and we are respecting the canon. Bestie, we’re about to get into regex match flags, and honestly it’s giving bitmask royalty. πŸ’…

🌸 NAME 🌸

std::regex_constants::match_flag_type β€” std::regex_constants::match_flag_type.

That’s it. That’s the name. The repetition is iconic, no notes. ✨

✨ Synopsis ✨

First up, the (until C++17) version:

Defined in header <regex>
using match_flag_type = /* implementation-defined */;  (1) (since C++11)

constexpr match_flag_type match_default =     {};
constexpr match_flag_type match_not_bol =     /* unspecified */;
constexpr match_flag_type match_not_eol =     /* unspecified */;
constexpr match_flag_type match_not_bow =     /* unspecified */;
constexpr match_flag_type match_not_eow =     /* unspecified */;
constexpr match_flag_type match_any =         /* unspecified */;
constexpr match_flag_type match_not_null =    /* unspecified */;  (since C++11)
constexpr match_flag_type match_continuous =  /* unspecified */;
constexpr match_flag_type match_prev_avail =  /* unspecified */;
constexpr match_flag_type format_default =    {};
constexpr match_flag_type format_sed =        /* unspecified */;
constexpr match_flag_type format_no_copy =    /* unspecified */;

constexpr match_flag_type format_first_only = /* unspecified */;

Then (since C++17) rolls in with inline constexpr and a (2) marker on match_default:

inline constexpr match_flag_type match_default =     {};  (2)
inline constexpr match_flag_type match_not_bol = /* unspecified */;
inline constexpr match_flag_type match_not_eol = /* unspecified */;
inline constexpr match_flag_type match_not_bow = /* unspecified */;
inline constexpr match_flag_type match_not_eow = /* unspecified */;
inline constexpr match_flag_type match_any = /* unspecified */;
inline constexpr match_flag_type match_not_null = /* unspecified */;
inline constexpr match_flag_type match_continuous = /* unspecified */;
inline constexpr match_flag_type match_prev_avail = /* unspecified */;
inline constexpr match_flag_type format_default = {};
inline constexpr match_flag_type format_sed = /* unspecified */;
inline constexpr match_flag_type format_no_copy = /* unspecified */;

inline constexpr match_flag_type format_first_only = /* unspecified */;

(1) match_flag_type is a BitmaskType that specifies additional regular expression matching options. 🫢

πŸ’… Constants πŸ’…

Note: [first, last) refers to the character sequence being matched.
  • match_not_bol β€” The first character in [first, last) will be treated as if it is not at the beginning of a line (i.e. ^ will not match [first, first)).
  • match_not_eol β€” The last character in [first, last) will be treated as if it is not at the end of a line (i.e. $ will not match [last, last)).
  • match_not_bow β€” \b will not match [first, first).
  • match_not_eow β€” \b will not match [last, last).
  • match_any β€” If more than one match is possible, then any match is an acceptable result.
  • match_not_null β€” Do not match empty sequences.
  • match_continuous β€” Only match a sub-sequence that begins at first.
  • match_prev_avail β€” --first is a valid iterator position. When set, causes match_not_bol and match_not_bow to be ignored.
  • format_default β€” Use ECMAScript rules to construct strings in std::regex_replace (syntax documentation).
  • format_sed β€” Use POSIX sed utility rules in std::regex_replace (syntax documentation).
  • format_no_copy β€” Do not copy un-matched strings to the output in std::regex_replace.
  • format_first_only β€” Only replace the first match in std::regex_replace.

All constants, except for match_default and format_default, are bitmask elements. The match_default and format_default constants are empty bitmasks. 🌈

🫢 Defect reports 🫢

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR LWG 2053, applied to C++11
    • Behavior as published:
      1. the constants were declared static
      2. match_default and format_default were initialized from 0
    • Correct behavior:
      1. removed the static specifier
      2. initialized from {}

πŸ‘‘ See also πŸ‘‘

  • regex_match (C++11) β€” attempts to match a regular expression to an entire character sequence (function template).
  • syntax_option_type (C++11) β€” general options controlling regex behavior (typedef).
  • error_type (C++11) β€” describes different types of matching errors (typedef).

xoxo, your regex bestie πŸ’œ β€” source: http://cppreference.com, version/date: 2024.06.10, page: std::regex_...ch_flag_type(3). Slay. ✨

πŸ“¦ where this page comes from