Getting started#
Install, then a first match. The drop-in pages cover swapping an API you already use.
Install#
Channel |
Command |
|---|---|
Homebrew (macOS / Linux) |
|
PyPI |
|
crates.io |
|
Go |
|
vcpkg |
|
CMake FetchContent |
|
Vendored |
copy |
The C++ library is header-only: installing places the headers. C++20 is
required; every header asserts it. Consume with CMake
(find_package(real CONFIG) + real::real), pkg-config --cflags real, or
a plain -I. The SciForge harness is
for the test suite, never for the library.
Compile the engine once#
Every translation unit that includes <real/real.hpp> compiles the engine
and its Unicode tables: several seconds per file at -O2. A project with
many such files can build the engine once instead, as a library, and include
a header that reaches none of it:
# configure REAL with -DREAL_BUILD_CAPI=ON, then:
find_package(real CONFIG REQUIRED)
target_link_libraries(app PRIVATE real::capi)
#include <real_compiled.hpp>
const real::compiled::regex re {R"((\w+)@(\w+))"};
if (const auto m {re.search("mail bob@host now")}) {
std::string_view user {m.str(1)}; // "bob"
}
A file that includes it compiles in under a second. real::compiled has
search, match and fullmatch over a region, find_all, count, sub
and group names; results own their spans, so they outlive the regex. What it
gives up is the header-only engine’s: static_regex, inlining into the
caller, the compatibility layers. The library is static or shared
(BUILD_SHARED_LIBS), and real_capi.h beside it is the same interface in C.
First match#
The same snippets the landing shows — compiled and run by CI, not illustrations.
// The pattern lives in the type — parsed & compiled at compile time.
#include <real/real.hpp>
constexpr real::static_regex<R"((\w+)@(\w+))"> email;
static_assert(email.search("info@example.com")[2] == "example");
import real as re # drop-in for the standard library's re
m = re.search(r"(\w+)@(\w+)", "info@example.com")
m.group(2) # 'example' — linear time, no backtracking cliff
use real_regex::Regex; // drop-in for the regex crate
let re = Regex::new(r"(\w+)@(\w+)")?;
let caps = re.captures("info@example.com").unwrap();
&caps[2]; // "example"
import real "github.com/RECHE23/real-regex/bindings/go"
re := real.MustCompile(`\d+`)
fmt.Print(re.MatchString("x42"))
Next#
Drop-in — swap
std::regex, RE2, Pythonre, the Rustregexcrate, or Goregexp.Features — every construct the engine accepts or refuses.
How it compares — the capability picture; the measured ledger stays on GitHub.
API reference — curated per-object pages.