wex
v21.10.0
|
This class offers regular expression matching. More...
#include <wex/regex.h>
Public Types | |
typedef std::vector< std::string > | match_t |
Type that specifies the matches. | |
typedef std::function< void(const match_t &)> | function_t |
Callback type. | |
typedef std::vector< std::string > | regex_v_t |
Type that specifies a vector with regular expressions. | |
typedef std::vector< std::pair< std::string, function_t > > | regex_v_c_t |
Type that specifies a vector with regular expressions and callbacks. | |
Public Member Functions | |
regex (const std::string ®ex, std::regex::flag_type flags=std::regex::ECMAScript) | |
Constructor, provide regular expression string and regex flags. | |
regex (const std::string ®ex, function_t f, std::regex::flag_type flags=std::regex::ECMAScript) | |
Constructor, provide regular expression string, callback and regex flags. | |
regex (const regex_v_t ®ex, std::regex::flag_type flags=std::regex::ECMAScript) | |
Constructor, provide vector with regular expressions and regex flags. | |
regex (const regex_v_c_t ®ex, std::regex::flag_type flags=std::regex::ECMAScript) | |
Constructor, provide vector with regular expressions, callbacks and regex flags. | |
int | match (const std::string &text) |
Regular expression match. More... | |
const auto & | matches () const |
Returns the (sub)matches. | |
const std::string & | operator[] (size_t pos) const |
Returns reference to the requested submatch element. | |
bool | replace (std::string &text, const std::string &replacement, std::regex_constants::match_flag_type=std::regex_constants::format_sed) const |
After match or search, replace text with replacement. More... | |
int | search (const std::string &text) |
Regular expression search. More... | |
auto | size () const |
Returns number of submatches. | |
const auto & | which () const |
Returns the tuple element that matched. | |
auto | which_no () const |
Returns the regex tuple no that matched, or -1 if no match was found. | |
This class offers regular expression matching.
int wex::regex::match | ( | const std::string & | text | ) |
Regular expression match.
Returns:
bool wex::regex::replace | ( | std::string & | text, |
const std::string & | replacement, | ||
std::regex_constants::match_flag_type | = std::regex_constants::format_sed |
||
) | const |
After match or search, replace text with replacement.
Returns true if a regex is available, and regex_replace was invoked.
int wex::regex::search | ( | const std::string & | text | ) |
Regular expression search.
Returns: