An opinionated and permissive ECMA 262 + RFC 9485 (best effort) regex implementation for JSON Schema. More...
Classes | |
| struct | sourcemeta::core::RegexTypeNonEmpty |
| struct | sourcemeta::core::RegexTypePCRE2 |
| struct | sourcemeta::core::RegexTypeNoop |
Typedefs | |
| using | sourcemeta::core::RegexTypePrefix = std::string |
| using | sourcemeta::core::RegexTypeRange = std::pair<std::size_t, std::size_t> |
| using | sourcemeta::core::Regex |
Enumerations | |
| enum class | sourcemeta::core::RegexDialect : std::uint8_t { RegexDialect::Permissive , RegexDialect::IRegexp , RegexDialect::IRegexpSearch } |
Functions | |
| SOURCEMETA_CORE_REGEX_EXPORT auto | sourcemeta::core::to_regex (const std::string_view pattern, const RegexDialect dialect=RegexDialect::Permissive, const bool optimise_for_match=true) -> std::optional< Regex > |
| SOURCEMETA_CORE_REGEX_EXPORT auto | sourcemeta::core::matches (const Regex ®ex, const std::string_view value) -> bool |
| SOURCEMETA_CORE_REGEX_EXPORT auto | sourcemeta::core::matches_if_valid (const std::string_view pattern, const std::string_view value, const RegexDialect dialect=RegexDialect::Permissive) -> bool |
| SOURCEMETA_CORE_REGEX_EXPORT auto | sourcemeta::core::replace_all (const Regex ®ex, const std::string_view subject, const std::string_view replacement) -> std::string |
| SOURCEMETA_CORE_REGEX_EXPORT auto | sourcemeta::core::is_regex_ecma (const std::string_view pattern) -> bool |
An opinionated and permissive ECMA 262 + RFC 9485 (best effort) regex implementation for JSON Schema.
This functionality is included as follows:
| struct sourcemeta::core::RegexTypeNonEmpty |
| struct sourcemeta::core::RegexTypePCRE2 |
| struct sourcemeta::core::RegexTypeNoop |
| using sourcemeta::core::Regex |
A compiled regular expression in one of its supported representations.
| using sourcemeta::core::RegexTypePrefix = std::string |
Matches any string that begins with a fixed prefix.
| using sourcemeta::core::RegexTypeRange = std::pair<std::size_t, std::size_t> |
Matches any string whose length falls within an inclusive range.
|
strong |
The dialects that a regular expression pattern can be interpreted with.
| SOURCEMETA_CORE_REGEX_EXPORT auto sourcemeta::core::is_regex_ecma | ( | const std::string_view | pattern | ) | -> bool |
Check whether the given string is a valid ECMA-262 regular expression. For example:
| SOURCEMETA_CORE_REGEX_EXPORT auto sourcemeta::core::matches | ( | const Regex & | regex, |
| const std::string_view | value ) -> bool |
Validate a string against a regular expression. For example:
| SOURCEMETA_CORE_REGEX_EXPORT auto sourcemeta::core::matches_if_valid | ( | const std::string_view | pattern, |
| const std::string_view | value, | ||
| const RegexDialect | dialect = RegexDialect::Permissive ) -> bool |
Validate a string against a regular expression pattern if the pattern represents a valid regular expression, compiling it along the way. For example:
| SOURCEMETA_CORE_REGEX_EXPORT auto sourcemeta::core::replace_all | ( | const Regex & | regex, |
| const std::string_view | subject, | ||
| const std::string_view | replacement ) -> std::string |
Replace every match of a regular expression with the given text, which is inserted literally. The regular expression must have been compiled without optimising for matching, and the behaviour is undefined otherwise. A subject that exhausts a matching resource is left alone, just as it would count as a failure to match. For example:
| SOURCEMETA_CORE_REGEX_EXPORT auto sourcemeta::core::to_regex | ( | const std::string_view | pattern, |
| const RegexDialect | dialect = RegexDialect::Permissive, | ||
| const bool | optimise_for_match = true ) -> std::optional< Regex > |
Compile a regular expression from a string. If the regular expression is invalid, no value is returned. In this function:
For example: