PCRE2 C++ Wrapper 1.3.0
pcre2cpp
Loading...
Searching...
No Matches
PCRE2 C++

Main group. More...

Collaboration diagram for PCRE2 C++:

Topics

 Utilities
 group with utilities (not for end user to use)

Classes

class  pcre2cpp::basic_pcre2cpp_exception< utf >
 base pcre2cpp exception class More...
class  pcre2cpp::basic_regex_exception< utf >
 regex exception class More...
class  pcre2cpp::basic_match_result_exception< utf >
 match result exception class More...
struct  pcre2cpp::basic_match_value< utf >
 Match value container. More...
struct  pcre2cpp::sub_match_value
 Sub match value container. More...
class  pcre2cpp::basic_match_result< utf >
 Basic container to result data of match function. More...
class  pcre2cpp::basic_regex< utf >
 Basic PCRE2 Regex container. More...

Macros

#define PCRE2CPP_VERSION_MAJOR   1
 pcre2cpp version major number
#define PCRE2CPP_VERSION_MINOR   3
 pcre2cpp version minor number
#define PCRE2CPP_VERSION_PATCH   0
 pcre2cpp version patch number
#define PCRE2CPP_VERSION_STRING   _PCRE2CPP_VERSION_TO_STRING(PCRE2CPP_VERSION_MAJOR, PCRE2CPP_VERSION_MINOR, PCRE2CPP_VERSION_PATCH)
 pcre2cpp version string
#define PCRE2CPP_VERSION_INT   _PCRE2CPP_VERSION_TO_INT(PCRE2CPP_VERSION_MAJOR, PCRE2CPP_VERSION_MINOR, PCRE2CPP_VERSION_PATCH)
 pcre2cpp version int
#define PCRE2CPP_VERSION   PCRE2CPP_VERSION_STRING
 pcre2cpp version string
#define PCRE2CPP_LAST_UPDATE_DAY   19
 pcre2cpp last update day
#define PCRE2CPP_LAST_UPDATE_MONTH   05
 pcre2cpp last update month
#define PCRE2CPP_LAST_UPDATE_YEAR   2026
 pcre2cpp last update year
#define PCRE2CPP_LAST_UPDATE_DATE   _PCRE2CPP_LAST_UPDATE_DATE_HELPER(PCRE2CPP_LAST_UPDATE_DAY, PCRE2CPP_LAST_UPDATE_MONTH, PCRE2CPP_LAST_UPDATE_YEAR)
 pcre2cpp last update date string

Typedefs

using pcre2cpp::match_options = mstd::flags<match_options_bits>
 Match options flags group.
using pcre2cpp::compile_options = mstd::flags<compile_options_bits>
 Compile options flags group.

Enumerations

enum class  pcre2cpp::match_error_codes : int32_t {
  pcre2cpp::match_error_codes::None = 1 , pcre2cpp::match_error_codes::NoMatch = PCRE2_ERROR_NOMATCH , pcre2cpp::match_error_codes::Partial = PCRE2_ERROR_PARTIAL , pcre2cpp::match_error_codes::BadMagic = PCRE2_ERROR_BADMAGIC ,
  pcre2cpp::match_error_codes::BadMode = PCRE2_ERROR_BADMODE , pcre2cpp::match_error_codes::BadOffset = PCRE2_ERROR_BADOFFSET , pcre2cpp::match_error_codes::BadOption = PCRE2_ERROR_BADOPTION , pcre2cpp::match_error_codes::BadUTFOffset = PCRE2_ERROR_BADUTFOFFSET ,
  pcre2cpp::match_error_codes::Callout = PCRE2_ERROR_CALLOUT , pcre2cpp::match_error_codes::DepthLimit = PCRE2_ERROR_DEPTHLIMIT , pcre2cpp::match_error_codes::HeapLimit = PCRE2_ERROR_HEAPLIMIT , pcre2cpp::match_error_codes::Internal = PCRE2_ERROR_INTERNAL ,
  pcre2cpp::match_error_codes::JITStackLimit = PCRE2_ERROR_JIT_STACKLIMIT , pcre2cpp::match_error_codes::MatchLimit = PCRE2_ERROR_MATCHLIMIT , pcre2cpp::match_error_codes::NoMemory = PCRE2_ERROR_NOMEMORY , pcre2cpp::match_error_codes::Null = PCRE2_ERROR_NULL ,
  pcre2cpp::match_error_codes::RecurseLoop = PCRE2_ERROR_RECURSELOOP
}
 Error codes which can be returned when match fail (now not used but maybe in future). More...
enum class  pcre2cpp::match_options_bits : uint32_t {
  pcre2cpp::match_options_bits::None = 0u , pcre2cpp::match_options_bits::Anchored = PCRE2_ANCHORED , pcre2cpp::match_options_bits::CopyMatchedSubject = PCRE2_COPY_MATCHED_SUBJECT , pcre2cpp::match_options_bits::DisableRecurseLoopCheck = PCRE2_DISABLE_RECURSELOOP_CHECK ,
  pcre2cpp::match_options_bits::EndAnchored = PCRE2_ENDANCHORED , pcre2cpp::match_options_bits::NotBOL = PCRE2_NOTBOL , pcre2cpp::match_options_bits::NotEOL = PCRE2_NOTEOL , pcre2cpp::match_options_bits::NotEmpty = PCRE2_NOTEMPTY ,
  pcre2cpp::match_options_bits::NotEmptyAtStart = PCRE2_NOTEMPTY_ATSTART , pcre2cpp::match_options_bits::NoJIT = PCRE2_NO_JIT , pcre2cpp::match_options_bits::NoUTFCheck = PCRE2_NO_UTF_CHECK , pcre2cpp::match_options_bits::PartialHard = PCRE2_PARTIAL_HARD ,
  pcre2cpp::match_options_bits::PartialSoft = PCRE2_PARTIAL_SOFT
}
 Match options. More...
enum class  pcre2cpp::compile_options_bits : uint32_t {
  pcre2cpp::compile_options_bits::None = 0u , pcre2cpp::compile_options_bits::Anchored = PCRE2_ANCHORED , pcre2cpp::compile_options_bits::AllowEmptyClass = PCRE2_ALLOW_EMPTY_CLASS , pcre2cpp::compile_options_bits::AltBSUX = PCRE2_ALT_BSUX ,
  pcre2cpp::compile_options_bits::AltCircumflex = PCRE2_ALT_CIRCUMFLEX , pcre2cpp::compile_options_bits::AltVerbNames = PCRE2_ALT_VERBNAMES , pcre2cpp::compile_options_bits::AutoCallout = PCRE2_AUTO_CALLOUT , pcre2cpp::compile_options_bits::Caseless = PCRE2_CASELESS ,
  pcre2cpp::compile_options_bits::DollarEndonly = PCRE2_DOLLAR_ENDONLY , pcre2cpp::compile_options_bits::DotAll = PCRE2_DOTALL , pcre2cpp::compile_options_bits::DupNames = PCRE2_DUPNAMES , pcre2cpp::compile_options_bits::EndAnchored = PCRE2_ENDANCHORED ,
  pcre2cpp::compile_options_bits::Extended = PCRE2_EXTENDED , pcre2cpp::compile_options_bits::FirstLine = PCRE2_FIRSTLINE , pcre2cpp::compile_options_bits::Literal = PCRE2_LITERAL , pcre2cpp::compile_options_bits::MatchInvalidUTF = PCRE2_MATCH_INVALID_UTF ,
  pcre2cpp::compile_options_bits::MatchUnsetBackRef = PCRE2_MATCH_UNSET_BACKREF , pcre2cpp::compile_options_bits::Multiline = PCRE2_MULTILINE , pcre2cpp::compile_options_bits::NeverBackslashC = PCRE2_NEVER_BACKSLASH_C , pcre2cpp::compile_options_bits::NeverUCP = PCRE2_NEVER_UCP ,
  pcre2cpp::compile_options_bits::NeverUTF = PCRE2_NEVER_UTF , pcre2cpp::compile_options_bits::NoAutoCapture = PCRE2_NO_AUTO_CAPTURE , pcre2cpp::compile_options_bits::NoAutoPossess = PCRE2_NO_AUTO_POSSESS , pcre2cpp::compile_options_bits::NoDotStarAnchor = PCRE2_NO_DOTSTAR_ANCHOR ,
  pcre2cpp::compile_options_bits::NoStartOptimize = PCRE2_NO_START_OPTIMIZE , pcre2cpp::compile_options_bits::NoUTFCheck = PCRE2_NO_UTF_CHECK , pcre2cpp::compile_options_bits::UCP = PCRE2_UCP , pcre2cpp::compile_options_bits::UnGreedy = PCRE2_UNGREEDY ,
  pcre2cpp::compile_options_bits::UseOffsetLimit = PCRE2_USE_OFFSET_LIMIT , pcre2cpp::compile_options_bits::UTF = PCRE2_UTF
}
 Compile options. More...
enum class  pcre2cpp::utf_type : uint8_t { pcre2cpp::utf_type::UTF_8 = 8 , pcre2cpp::utf_type::UTF_16 = 16 , pcre2cpp::utf_type::UTF_32 = 32 }
 Enum with supported utf types. More...

Functions

template<utf_type utf>
static _PCRE2CPP_CONSTEXPR17 utils::pcre2_data< utf >::string_type pcre2cpp::generate_error_message (const int error_code) noexcept
 Function which generate error message based on pcre2 error code.
template<utf_type utf>
static _PCRE2CPP_CONSTEXPR17 utils::pcre2_data< utf >::string_type pcre2cpp::generate_error_message (const int error_code, const size_t error_offset) noexcept
 Function which generates error message based on pcre2 error code and with additional information about offset.
template<utf_type utf>
static _PCRE2CPP_CONSTEXPR20 std::string pcre2cpp::convert_any_utf_to_utf8 (const typename utils::pcre2_data< utf >::string_view_type message) noexcept
 converts any message from any utf to utf-8
static _PCRE2CPP_CONSTEXPR17 match_options pcre2cpp::operator| (const match_options_bits opt0, const match_options_bits opt1) noexcept
 operator for combining match options to one flags group

Variables

static constexpr auto pcre2cpp::default_utf_type
 default utf type for types like regex etc...

Detailed Description

Main group.

Macro Definition Documentation

◆ PCRE2CPP_LAST_UPDATE_DATE

◆ PCRE2CPP_LAST_UPDATE_DAY

#define PCRE2CPP_LAST_UPDATE_DAY   19

pcre2cpp last update day

◆ PCRE2CPP_LAST_UPDATE_MONTH

#define PCRE2CPP_LAST_UPDATE_MONTH   05

pcre2cpp last update month

◆ PCRE2CPP_LAST_UPDATE_YEAR

#define PCRE2CPP_LAST_UPDATE_YEAR   2026

pcre2cpp last update year

◆ PCRE2CPP_VERSION

#define PCRE2CPP_VERSION   PCRE2CPP_VERSION_STRING

pcre2cpp version string

◆ PCRE2CPP_VERSION_INT

◆ PCRE2CPP_VERSION_MAJOR

#define PCRE2CPP_VERSION_MAJOR   1

pcre2cpp version major number

◆ PCRE2CPP_VERSION_MINOR

#define PCRE2CPP_VERSION_MINOR   3

pcre2cpp version minor number

◆ PCRE2CPP_VERSION_PATCH

#define PCRE2CPP_VERSION_PATCH   0

pcre2cpp version patch number

◆ PCRE2CPP_VERSION_STRING

Typedef Documentation

◆ compile_options

Compile options flags group.

◆ match_options

Match options flags group.

Enumeration Type Documentation

◆ compile_options_bits

enum class pcre2cpp::compile_options_bits : uint32_t
strong

Compile options.

Enumerator
None 0u 

No options set (default).

Anchored PCRE2_ANCHORED 

Force pattern anchoring.

AllowEmptyClass PCRE2_ALLOW_EMPTY_CLASS 

Allow empty classes.

AltBSUX PCRE2_ALT_BSUX 

Alternative handling of \u, \U, and \x.

AltCircumflex PCRE2_ALT_CIRCUMFLEX 

Alternative handling of ^ in multiline mode.

AltVerbNames PCRE2_ALT_VERBNAMES 

Process backslashes in verb names.

AutoCallout PCRE2_AUTO_CALLOUT 

Compile automatic callouts.

Caseless PCRE2_CASELESS 

Do caseless matching.

DollarEndonly PCRE2_DOLLAR_ENDONLY 

$ not to match newline at end

DotAll PCRE2_DOTALL 

. matches anything including NL

DupNames PCRE2_DUPNAMES 

Allow duplicate names for subpatterns.

EndAnchored PCRE2_ENDANCHORED 

Pattern can match only at end of subject.

Extended PCRE2_EXTENDED 

Ignore white space and # comments.

FirstLine PCRE2_FIRSTLINE 

Force matching to be before newline.

Literal PCRE2_LITERAL 

Pattern characters are all literal.

MatchInvalidUTF PCRE2_MATCH_INVALID_UTF 

Enable support for matching invalid UTF.

MatchUnsetBackRef PCRE2_MATCH_UNSET_BACKREF 

Match unset backreferences.

Multiline PCRE2_MULTILINE 

^ and $ match newlines within data

NeverBackslashC PCRE2_NEVER_BACKSLASH_C 

Lock out the use of \C in patterns.

NeverUCP PCRE2_NEVER_UCP 

Lock out PCRE2_UCP, e.g.via(*UCP).

NeverUTF PCRE2_NEVER_UTF 

Lock out PCRE2_UTF, e.g.via(*UTF).

NoAutoCapture PCRE2_NO_AUTO_CAPTURE 

Disable numbered capturing paren - theses(named ones available).

NoAutoPossess PCRE2_NO_AUTO_POSSESS 

Disable auto - possessification.

NoDotStarAnchor PCRE2_NO_DOTSTAR_ANCHOR 

Disable automatic anchoring for .*.

NoStartOptimize PCRE2_NO_START_OPTIMIZE 

Disable match - time start optimizations.

NoUTFCheck PCRE2_NO_UTF_CHECK 

Do not check the pattern for UTF validity (only relevant if PCRE2_UTF is set).

UCP PCRE2_UCP 

Use Unicode properties for \d, \w, etc.

UnGreedy PCRE2_UNGREEDY 

Invert greediness of quantifiers.

UseOffsetLimit PCRE2_USE_OFFSET_LIMIT 

Enable offset limit for unanchored matching.

UTF PCRE2_UTF 

Treat pattern and subjects as UTF strings.

◆ match_error_codes

enum class pcre2cpp::match_error_codes : int32_t
strong

Error codes which can be returned when match fail (now not used but maybe in future).

Enumerator
None 

No error (default).

NoMatch PCRE2_ERROR_NOMATCH 

The subject string did not match the pattern.

Partial PCRE2_ERROR_PARTIAL 

The subject string did not match, but it did match partially.

BadMagic PCRE2_ERROR_BADMAGIC 

PCRE2 stores a 4-byte "magic number" at the start of the compiled code, to catch the case when it is passed a junk pointer. This is the error that is returned when the magic number is not present

BadMode PCRE2_ERROR_BADMODE 

This error is given when a compiled pattern is passed to a function in a library of a different code unit width, for example, a pattern compiled by the 8-bit library is passed to a 16-bit or 32-bit library function.

BadOffset PCRE2_ERROR_BADOFFSET 

The value of startoffset was greater than the length of the subject.

BadOption PCRE2_ERROR_BADOPTION 

An unrecognized bit was set in the options argument.

BadUTFOffset PCRE2_ERROR_BADUTFOFFSET 

The UTF code unit sequence that was passed as a subject was checked and found to be valid (the match_option::NoUTFCheck option was not set), but the value of startoffset did not point to the beginning of a UTF character or the end of the subject.

Callout PCRE2_ERROR_CALLOUT 

This error is never generated by pcre2_match() itself. It is provided for use by callout functions that want to cause pcre2_match() or pcre2_callout_enumerate() to return a distinctive error code.

DepthLimit PCRE2_ERROR_DEPTHLIMIT 

The nested backtracking depth limit was reached.

HeapLimit PCRE2_ERROR_HEAPLIMIT 

The heap limit was reached.

Internal PCRE2_ERROR_INTERNAL 

An unexpected internal error has occurred. This error could be caused by a bug in PCRE2 or by overwriting of the compiled pattern.

JITStackLimit PCRE2_ERROR_JIT_STACKLIMIT 

This error is returned when a pattern that was successfully studied using JIT is being matched, but the memory available for the just-in-time processing stack is not large enough.

MatchLimit PCRE2_ERROR_MATCHLIMIT 

The backtracking match limit was reached.

NoMemory PCRE2_ERROR_NOMEMORY 

Heap memory is used to remember backtracking points. This error is given when the memory allocation function (default or custom) fails. Note that a different error, PCRE2_ERROR_HEAPLIMIT, is given if the amount of memory needed exceeds the heap limit. match_error_codes::NoMemory is also returned if match_options_bits::CopyMatchedSubject is set and memory allocation fails.

Null PCRE2_ERROR_NULL 

Either the code, subject, or match_data argument was passed as nullptr.

RecurseLoop PCRE2_ERROR_RECURSELOOP 

This error is returned when pcre2_match() detects a recursion loop within the pattern. Specifically, it means that either the whole pattern or a capture group has been called recursively for the second time at the same position in the subject string. Some simple patterns that might do this are detected and faulted at compile time, but more complicated cases, in particular mutual recursions between two different groups, cannot be detected until matching is attempted.

◆ match_options_bits

enum class pcre2cpp::match_options_bits : uint32_t
strong

Match options.

Enumerator
None 0u 

No options set (default).

Anchored PCRE2_ANCHORED 

Match only at the first position.

CopyMatchedSubject PCRE2_COPY_MATCHED_SUBJECT 

On success, make a private subject copy.

DisableRecurseLoopCheck PCRE2_DISABLE_RECURSELOOP_CHECK 

Only useful in rare cases; use with care.

EndAnchored PCRE2_ENDANCHORED 

Pattern can match only at end of subject.

NotBOL PCRE2_NOTBOL 

Subject string is not the beginning of a line.

NotEOL PCRE2_NOTEOL 

Subject string is not the end of a line.

NotEmpty PCRE2_NOTEMPTY 

An empty string is not a valid match.

NotEmptyAtStart PCRE2_NOTEMPTY_ATSTART 

An empty string at the start of the subject is not a valid match.

NoJIT PCRE2_NO_JIT 

Do not use JIT matching.

NoUTFCheck PCRE2_NO_UTF_CHECK 

Do not check the subject for UTF validity(only relevant if compile_options::UTF was set at compile time).

PartialHard PCRE2_PARTIAL_HARD 

Return match_error_codes::Partial for a partial match even if there is a full match.

PartialSoft PCRE2_PARTIAL_SOFT 

Return match_error_codes::Partial for a partial match if no full matches are found.

◆ utf_type

enum class pcre2cpp::utf_type : uint8_t
strong

Enum with supported utf types.

Enumerator
UTF_8 

value for UTF-8 support

UTF_16 16 

value for UTF-16 support

UTF_32 32 

value for UTF-32 support

Function Documentation

◆ convert_any_utf_to_utf8()

template<utf_type utf>
_PCRE2CPP_CONSTEXPR20 std::string pcre2cpp::convert_any_utf_to_utf8 ( const typename utils::pcre2_data< utf >::string_view_type message)
staticnoexcept

converts any message from any utf to utf-8

Template Parameters
utfUTF type
Parameters
messagemessage to convert
Returns
std::string value of message

◆ generate_error_message() [1/2]

template<utf_type utf>
_PCRE2CPP_CONSTEXPR17 utils::pcre2_data< utf >::string_type pcre2cpp::generate_error_message ( const int error_code)
staticnoexcept

Function which generate error message based on pcre2 error code.

Template Parameters
utfUTF type
Parameters
error_codepcre2 error code
Returns
string value of type compatible with UTF type

◆ generate_error_message() [2/2]

template<utf_type utf>
_PCRE2CPP_CONSTEXPR17 utils::pcre2_data< utf >::string_type pcre2cpp::generate_error_message ( const int error_code,
const size_t error_offset )
staticnoexcept

Function which generates error message based on pcre2 error code and with additional information about offset.

Template Parameters
utfUTF type
Parameters
error_codepcre2 error code
error_offsetoffset for example in regex pattern
Returns
string value of type compatible with UTF type

◆ operator|()

_PCRE2CPP_CONSTEXPR17 match_options pcre2cpp::operator| ( const match_options_bits opt0,
const match_options_bits opt1 )
staticnoexcept

operator for combining match options to one flags group

Parameters
opt0first match option
opt1second match option
Returns
Match options flags group created from two match options

Variable Documentation

◆ default_utf_type

auto pcre2cpp::default_utf_type
staticconstexpr
Initial value:
=
@ UTF_8
value for UTF-8 support
Definition pcre2_data.hpp:34

default utf type for types like regex etc...