BSON_APPEND_REGEX(3)
π BSON_APPEND_REGEX π
okay bestie, this one's from the libbson girlies β it's the BSON_APPEND_REGEX(3) page and honestly it's giving "small function, big slay" β¨
β¨ SYNOPSIS β¨
so there's a macro and a function, because of course there is π
#define BSON_APPEND_REGEX(b, key, val, opt) \
bson_append_regex (b, key, (int) strlen (key), val, opt)
bool
bson_append_regex (bson_t *bson,
const char *key,
int key_length,
const char *regex,
const char *options);
like, the macro is just the function but it does the strlen() for you so you don't have to. main character energy honestly π
πΈ PARAMETERS πΈ
bsonβ abson_t. that's the whole vibe. the document you're adding to πkeyβ an ASCII C string with the name of the field. yep. just the name. ngl ASCII only, keep it cute π¦key_lengthβ the length ofkeyin bytes, or-1if you want it to figure that out withstrlen(). lowkey the lazy-girl option and we respect it πregexβ an ASCII string containing the regex. the actual pattern, bestie π₯optionsβ an optional string containing the regex options as a string. optional!! so you can absolutely skip it π
π¦ DESCRIPTION π¦
so what it does: it appends a brand new field onto bson, and the type is BSON_TYPE_REGEX β iconic, we love a dedicated regex type π
regex should be the regex string. options should contain the options for the regex. simple, clean, no cap β¨
and the valid characters for options? bestie I got you, here's the whole list π
'i'β for case-insensitive. soABCandabcare the same thing, slay π'm'β for multiple matching π'x'β for verbose mode πΈ'l'β to makewandWlocale dependent. yep, the lowercase and uppercase ones, exactly those π's'β for dotall mode, which means'.'matches everything. every single thing. periodt β'u'β to makewandWmatch unicode π¦
fr fr, those are the exact characters β don't go inventing new ones, bestie π
β RETURNS β
Returns true if the operation was applied successfully. if it worked, it worked π
but heads up: the function will fail if appending the regex grows bson larger than INT32_MAX. like, that's the ceiling. if you blow past it, it's not happening, sorry not sorry π
π AUTHOR π
MongoDB, Inc β the literal authors, we stan π«Ά
π§ COPYRIGHT π§
2009-present, MongoDB, Inc. β all rights reserved, all vibes preserved πΈ
and that's the whole page, bestie!! this was libbson 2.5.6, dated Oct 09, 2026 β go forth and append those regexes, you absolute icon π
β¨π
π¦ 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