Data & serialization
CRegex
Compile a regular expression, match whole strings, or collect all occurrences.
C++23
mc/CRegex.h
#include <mc/CRegex.h>Copy
match() matches the entire input. Match outputs are appended; clear the destination first when replacing previous results.
Capture zero is the whole match. IgnoreCase enables case-insensitive matching. Invalid patterns throw CError .
Jump to a declaration · 11
CRegex
Types, constants & data
static constexpr uint32_t IgnoreCase = 0b01;
using Range = std::pair<uint32_t, uint32_t>;
Methods
Compiles the pattern, optionally ignoring case. Invalid syntax raises CError ; reuse the compiled object for repeated matches.
bool match(const char* text, Strings& matches) const;
bool match(const cstr & text, Strings& matches) const;
bool match(const char* text) const;
bool match(const cstr & text) const;
Requires the entire input to match the pattern. Capture overloads append the full match followed by capture groups to matches; a failed match leaves the output unchanged.
bool matchRanges(const char* text, Ranges& ranges) const;
bool matchRanges(const cstr & text, Ranges& ranges) const;
Matches the entire input and appends the full match and capture groups as (byte offset, byte length) pairs. These are lengths, not end offsets.
bool findAll(const char* text, CVector <Strings>& matches) const;
bool findAll(const cstr & text, CVector <Strings>& matches) const;
Finds successive matches anywhere in the input and appends one vector per match, containing the full match then capture groups. Returns whether at least one match was found.