Your opinion will help to improve our service
Leave a feedback >#include <userver/utils/regex.hpp>
A drop-in replacement for std::match_results
without huge includes and with better performance characteristics. Represents capturing groups of a single match result.
The group 0 always matches the whole pattern. User groups start with index 1.
Non-empty groups always point within the source string, so the position of a group within the source string can be obtained by subtracting .data()
pointers or .begin()
iterators.
std::string_view
s with data() == nullptr
or some invalid pointer with size() == 0
. Check for emptiness before performing pointer arithmetic if a group can be empty according to the regex!Public Member Functions | |
match_results () | |
match_results (const match_results &) | |
match_results & | operator= (const match_results &) |
std::size_t | size () const |
std::string_view | operator[] (std::size_t sub) const |
std::size_t | position (std::size_t sub) const |
std::size_t | length (std::size_t sub) const |
std::string_view | prefix () const |
std::string_view | suffix () const |
utils::match_results::match_results | ( | ) |
Constructs a null match_results
, any usage except for copy/move is UB. Filled upon successful regex_match or regex_search.
std::size_t utils::match_results::length | ( | std::size_t | sub | ) | const |
std::string_view utils::match_results::operator[] | ( | std::size_t | sub | ) | const |
std::size_t utils::match_results::position | ( | std::size_t | sub | ) | const |
std::string_view utils::match_results::prefix | ( | ) | const |
std::size_t utils::match_results::size | ( | ) | const |
std::string_view utils::match_results::suffix | ( | ) | const |
|
friend |
Returns true if the specified regular expression matches the whole of the input. Fills in what matched in m.
|
friend |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
friend |
Create a new string where all regular expression matches replaced with repl.
Interprets repl as a literal, does not support substitutions.
|
friend |
Determines whether the regular expression matches anywhere in the target character sequence. Fills in what matched in m.