---
name: "re_comp"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/re_comp"
---

# re\_comp(3)

BSD regex functions

## NAME

re\_comp, re\_exec - BSD regex functions

## LIBRARY

Standard C library (*libc*, *-lc*)

## 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***);**

## DESCRIPTION

**re\_comp**() is used to compile the null-terminated regular expression pointed to by *regex*. The compiled pattern occupies a static area, the pattern buffer, which is overwritten by subsequent use of **re\_comp**(). If *regex* is NULL, no operation is performed and the pattern buffer's contents are not altered.

**re\_exec**() is used to assess whether the null-terminated string pointed to by *string* matches the previously compiled *regex*.

## RETURN VALUE

**re\_comp**() returns NULL on successful compilation of *regex* otherwise it returns a pointer to an appropriate error message.

**re\_exec**() returns 1 for a successful match, zero for failure.

## ATTRIBUTES

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **re\_comp**(), **re\_exec**() | Thread safety | MT-Unsafe |

## STANDARDS

None.

## HISTORY

4\.3BSD.

These functions are obsolete; the functions documented in [**regcomp**(3)](/regcomp/3.md) should be used instead.

## SEE ALSO

[**regcomp**(3)](/regcomp/3.md), [**regex**(7)](/regex/7.md), GNU regex manual
