BSON_APPEND_REGEX_W_LEN(3)
β¨ hey bestie, meet bson_append_regex_w_len β¨
okay so this is a page from libbson, section 3 of the manual β it's all about bson_append_regex_w_len, and honestly it's giving "small function, big responsibilities" π
. Let's get into it fr fr.
πΈ SYNOPSIS πΈ
bool
bson_append_regex_w_len (bson_t *bson,
const char *key,
int key_length,
const char *regex,
int regex_length,
const char *options);
that's the whole signature, no cap. six params, one bool back. let's meet the cast π«Ά
π PARAMETERS π
bsonβ abson_t. the doc you're stuffing a field into. your main character, literally.keyβ an ASCII C string holding the name of the field. keep it ASCII bestie, no funny business.key_lengthβ how longkeyis, in bytes. or pass-1and it'll just figure it out withstrlen(). lazy girl summer, and honestly? valid.regexβ an ASCII string with the regex in it. the actual pattern, the whole point of the function πregex_lengthβ the length ofregexin bytes, or-1to letstrlen()do the counting for you. same deal as above β¨optionsβ an optional string with the regex options, as a string. optional optional, like you can hand it over or not π¦
π DESCRIPTION π
so what it does: it appends a brand-new field to bson, and that field is of type BSON_TYPE_REGEX π. regex should be the regex string, and options should carry the options for that regex.
the valid characters you can put in options are:
'i'for case-insensitive.'m'for multiple matching.'x'for verbose mode.'l'to makewandWlocale dependent.'s'for dotall mode ('.'matches everything).'u'to makewandWmatch unicode.
like, that's the whole menu. those six lil letters, each one doing its own iconic thing π
β RETURNS β
returns true if the operation was applied successfully π.
and here's the not-so-slay part: the function will fail if appending the regex growsbsonlarger thanINT32_MAX. that's the ceiling, and she is real π so check that return value, bestie, don't just assume it ate.
π¦ AUTHOR π¦
MongoDB, Inc β the ones who brought you this whole situation π
π§ COPYRIGHT π§
2009-present, MongoDB, Inc. β periodt, respect the copyright line fr fr π
and that's the page!! source/version 2.5.6, dated Oct 09, 2026, straight out of the libbson BSON_APPEND_REGEX_W_LEN(3) manual π ok bye, go append some regexes responsibly π
π¦ where this page comes from
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms