RGXG_UTILS_ESCAPE_STRING(3)
π RGXG_UTILS_ESCAPE_STRING π
okay bestie, sit down, hydrate, and let me tell you about rgxg_utils_escape_string from the librgxg manual (section 3, we're fancy like that). this one's a lil function that makes strings safe for regex land, and it's genuinely so useful. no cap. π¦
β¨ NAME β¨
rgxg_utils_escape_string β escape the given string for use in a regular expression
like. that's it. that's the whole job. it takes a string and makes it regex-safe so none of the special characters go feral on you. π
πΈ SYNOPSIS πΈ
#include <rgxg/utils.h>
int rgxg_utils_escape_string (const char *src, size_t size,
char *regex, rgxg_options_t options);
π DESCRIPTION π
so here's the tea, bestie. rgxg_utils_escape_string() generates the (extended) regular expression that matches at most size bytes of the given string src β or up to the first null byte, whichever comes first β and it does that by escaping the regular expression special characters. basically it takes your chaotic little string and gives it a glow-up so it behaves in a regex. π
lowkey important:srcmust be valid and notNULL. do not test this. it will not pass the vibe check.
the generated regular expression gets written to the character string regex, and yes it includes the terminating null byte ('\0') β UNLESS RGXG_NONULLBYTE is set, in which case it does not. iconique behavior. π
now, if regex is NULL, the return value is the number of characters (excluding the terminating null byte) that would have been written, in case regex had been initialized. it's giving "just tell me how much space i need, bestie." π
β οΈ heads up: these functions assume an arbitrarily long regex string. callers must ensure that the given string is large enough to not overflow the actual space. that's on you, not on the function. no safety net, fr fr.
options is either zero, or set to the following macro:
RGXG_NONULLBYTEβ Do not add the terminating null byte ('\0') to theregexstring.
π RETURN VALUE π
rgxg_utils_escape_string() returns the number of characters (excluding the terminating null byte) written to regex. so like, a count. a lil number. your receipt. π§Ύβ¨
π AVAILABILITY π
This function is available since rgxg 0.1. she's been here. she's a legend. periodt. π
π₯ SEE ALSO π₯
π«Ά AUTHOR π«Ά
Hannes von Haugwitz <hannes@vonhaugwitz.com>
and that's the whole page, bestie!! this lil beauty shipped in rgxg 0.1.2, dated Apr 12, 2020 β go forth and escape responsibly, mwah πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: librgxg-dev 0.1.2-5
- debian trixie: librgxg-dev 0.1.2-7
- nixos 26.05: rgxg 0.1.2
- nixpkgs unstable: rgxg 0.1.2
- ubuntu jammy: librgxg-dev 0.1.2-4
- ubuntu noble: librgxg-dev 0.1.2-5
- ubuntu questing: librgxg-dev 0.1.2-7
- ubuntu resolute: librgxg-dev 0.1.2-8
- ubuntu stonking: librgxg-dev 0.1.2-8
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms