1#ifndef SOURCEMETA_CORE_REGEX_H_
2#define SOURCEMETA_CORE_REGEX_H_
4#ifndef SOURCEMETA_CORE_REGEX_EXPORT
5#include <sourcemeta/core/regex_export.h>
27namespace sourcemeta::core {
46 std::shared_ptr<void>
code;
47 auto operator==(
const RegexTypePCRE2 &other)
const noexcept ->
bool {
48 return this->code == other.code;
54 auto operator==(
const RegexTypeNoop &)
const noexcept ->
bool =
default;
63enum class RegexIndex : std::uint8_t {
112SOURCEMETA_CORE_REGEX_EXPORT
115 const bool optimise_for_match =
true) -> std::optional<Regex>;
130SOURCEMETA_CORE_REGEX_EXPORT
145SOURCEMETA_CORE_REGEX_EXPORT
147 const std::string_view value,
169SOURCEMETA_CORE_REGEX_EXPORT
171 const std::string_view replacement) -> std::string;
186SOURCEMETA_CORE_REGEX_EXPORT
std::shared_ptr< void > code
The opaque handle to the compiled expression.
Definition regex.h:46
SOURCEMETA_CORE_REGEX_EXPORT auto to_regex(const std::string_view pattern, const RegexDialect dialect=RegexDialect::Permissive, const bool optimise_for_match=true) -> std::optional< Regex >
RegexDialect
Definition regex.h:74
std::string RegexTypePrefix
Definition regex.h:31
std::pair< std::size_t, std::size_t > RegexTypeRange
Definition regex.h:40
SOURCEMETA_CORE_REGEX_EXPORT auto matches_if_valid(const std::string_view pattern, const std::string_view value, const RegexDialect dialect=RegexDialect::Permissive) -> bool
std::variant< RegexTypePrefix, RegexTypeNonEmpty, RegexTypeRange, RegexTypePCRE2, RegexTypeNoop > Regex
Definition regex.h:59
SOURCEMETA_CORE_REGEX_EXPORT auto matches(const Regex ®ex, const std::string_view value) -> bool
SOURCEMETA_CORE_REGEX_EXPORT auto replace_all(const Regex ®ex, const std::string_view subject, const std::string_view replacement) -> std::string
SOURCEMETA_CORE_REGEX_EXPORT auto is_regex_ecma(const std::string_view pattern) -> bool
@ IRegexp
Definition regex.h:80
@ Permissive
A permissive superset of ECMA 262 with PCRE2 extensions.
Definition regex.h:76
@ IRegexpSearch
Definition regex.h:83