wex v24.10.0
|
This class offers regular expression matching. More...
#include <wex/core/regex.h>
Classes | |
class | data |
This class contains the regex data. More... | |
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::pair< std::string, function_t > | regex_c_t |
Type that specifies pair of regular expression and callback. | |
typedef std::vector< regex_c_t > | regex_v_c_t |
Type that specifies a vector with regular expressions and callbacks. | |
Public Member Functions | |
regex (const data &) | |
Constructor, provide regular expression data. | |
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. | |
const std::string | operator[] (size_t pos) const |
Returns requested submatch element. | |
const std::string | back () const |
Returns the last (sub)match. | |
bool | empty () const |
Returns true if matches is empty. | |
int | match (const std::string &text) |
Regular expression match. | |
const data | match_data () const |
Returns the data element that matched. | |
int | match_no () const |
Returns the data regex index that matched, or -1 if no match was found. | |
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. | |
int | search (const std::string &text) |
Regular expression search. | |
size_t | size () const |
Returns number of submatches. | |
This class offers regular expression matching.
const std::string wex::regex::back | ( | ) | const |
Returns the last (sub)match.
Returns empty string if no matches present.
int wex::regex::match | ( | const std::string & | text | ) |
Regular expression match.
Returns:
const std::string wex::regex::operator[] | ( | size_t | pos | ) | const |
Returns requested submatch element.
Returns empty string if pos beyond index.
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 the regex iterator is available, because of successful match or search.
int wex::regex::search | ( | const std::string & | text | ) |
Regular expression search.
Returns: