re_comp(3)

✨ re_comp, re_exec β€” the BSD regex girlies ✨

okay bestie, let's talk about re_comp(3) β€” she's a library functions manual girlie from the Standard C library, which lives in libc, also known as -lc when you're linking. yes, THE libc. iconic behavior. πŸ’…


🌸 SYNOPSIS 🌸

#define _REGEX_RE_COMP
#include <sys/types.h>
#include <regex.h>

[[deprecated]] char *re_comp(const char *regex);
[[deprecated]] int re_exec(const char *string);

see those [[deprecated]] tags? yeah. the compiler is literally side-eyeing you. πŸ‘€ she's old money, but not in a good way.


πŸ’– DESCRIPTION πŸ’–

so re_comp() compiles the null-terminated regular expression that regex is pointing at. no cap. ✨

and here's the tea: the compiled pattern doesn't go live in some cute lil malloc'd struct β€” it occupies a static area, bestie. it's called the pattern buffer. and the way that any subsequent call to re_comp() just overwrites it?? 😭 no warning, no nothing, just gone. one pattern at a time, that's the rule. main character energy, but like, the jealous kind.

oh and if regex is NULL? nothing happens. literally nothing. no operation is performed and the pattern buffer's contents are not altered. she just stands there. πŸ’€

then re_exec() β€” she's the vibe check 🫢. she assesses whether the null-terminated string that string points to matches the regular expression you previously compiled. previously being the key word, iykyk.


πŸŽ€ RETURN VALUE πŸŽ€

  • re_comp() returns NULL when regex compiled successfully β€” slay? no wait, NULL means success here, which is lowkey cursed but okay. otherwise she returns a pointer to an appropriate error message, so you can read exactly what went wrong. πŸ’…
  • re_exec() returns 1 for a successful match, and zero for failure. 1 = ate. 0 = flop. ✨

πŸ¦‹ ATTRIBUTES πŸ¦‹

for the explanation of the terms used in this section, go check out attributes(7). 🧚

  • Interface: re_comp(), re_exec()
  • Attribute: Thread safety
  • Value: MT-Unsafe
bestie. MT-Unsafe. that static pattern buffer we talked about? yeah. threads are not the vibe here. do not invite multiple threads to this party. πŸ™ˆ

⭐ STANDARDS ⭐

None. πŸ“­

like... none none. not a single standard claimed her. she's out here unstandardized and unbothered, floating free. πŸ’€


πŸ‘‘ HISTORY πŸ‘‘

4.3BSD.

that's it. that's the origin story. 🌈

these functions are obsolete β€” deadass, no sugarcoating β€” and the functions documented in regcomp(3) should be used instead. that's not me being dramatic, that's the manpage. she's telling you to move on. 🫢


πŸ’œ SEE ALSO πŸ’œ


🚨 a little warning from your girl: the static pattern buffer + MT-Unsafe combo means if you're in a multithreaded situation, this is a no. every re_comp() call nukes the last one, and nothing is thread-safe. also she's deprecated and obsolete. regcomp(3) is right there, bestie, she's waiting for you. πŸ’–

and that's the page, fr fr βœ¨πŸ’…πŸŽ€πŸ¦‹πŸŒΈπŸ«ΆπŸ˜­πŸ”₯πŸ‘‘πŸŒˆβ­πŸ’€πŸ™ˆπŸ“πŸ§šπŸ’œβœ¨

this lil love letter to obsolete BSD regex functions came to you courtesy of Linux man-pages 6.20, dated 2026-02-08 β€” go forth, use regcomp(3), and stay safe out there. mwah. πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms