Hermes
hermes::Str::regex Struct Reference

Static Public Member Functions

static bool match (const std::string &s, const std::string &pattern, std::regex_constants::match_flag_type flags=std::regex_constants::match_default)
 Checks if a string s matches exactly a regular expression. More...
 
static bool contains (const std::string &s, const std::string &pattern, std::regex_constants::match_flag_type flags=std::regex_constants::match_default)
 Checks if any substring of s matches a regular expression. More...
 
static std::smatch search (const std::string &s, const std::string &pattern, std::regex_constants::match_flag_type flags=std::regex_constants::match_default)
 Search the first substrings of s that matches the pattern. More...
 
static bool search (std::string s, const std::string &pattern, const std::function< void(const std::smatch &)> &callback, std::regex_constants::match_flag_type flags=std::regex_constants::match_default)
 Iterate over all substrings of s that match the pattern. More...
 
static std::string replace (const std::string &s, const std::string &pattern, const std::string &format, std::regex_constants::match_flag_type flags=std::regex_constants::match_default)
 Replaces all matches of pattern in s by format. More...
 

Static Public Attributes

static const char floating_point_number [] = "[-+]?[0-9]*\\.?[0-9]*e?[-+]?[0-9]+"
 
static const char integer_number [] = "[-+]?[0-9]+"
 
static const char alpha_numeric_word [] = "[a-zA-Z0-9]+"
 
static const char c_identifier [] = "[_a-zA-Z]+[0-9a-zA-Z_]*"
 

Member Function Documentation

◆ contains()

bool hermes::Str::regex::contains ( const std::string &  s,
const std::string &  pattern,
std::regex_constants::match_flag_type  flags = std::regex_constants::match_default 
)
static

Checks if any substring of s matches a regular expression.

Parameters
sinput string
patternregex pattern
flags[optional] controls how pattern is matched
Returns
true if s contains the pattern

◆ match()

bool hermes::Str::regex::match ( const std::string &  s,
const std::string &  pattern,
std::regex_constants::match_flag_type  flags = std::regex_constants::match_default 
)
static

Checks if a string s matches exactly a regular expression.

Parameters
sinput string
patternregex pattern
flags[optional] controls how pattern is matched
Returns
true if s matches exactly the pattern

◆ replace()

std::string hermes::Str::regex::replace ( const std::string &  s,
const std::string &  pattern,
const std::string &  format,
std::regex_constants::match_flag_type  flags = std::regex_constants::match_default 
)
static

Replaces all matches of pattern in s by format.

Parameters
sinput string
patternregular expression pattern
formatreplacement format
flags[optional] controls how pattern is matched and how format is replaced
Returns
A copy of s with all replacements

◆ search() [1/2]

std::smatch hermes::Str::regex::search ( const std::string &  s,
const std::string &  pattern,
std::regex_constants::match_flag_type  flags = std::regex_constants::match_default 
)
static

Search the first substrings of s that matches the pattern.

Parameters
sinput string
patternregular expression pattern
flags[optional] controls how pattern is matched
Returns
std match object containing the first match

◆ search() [2/2]

bool hermes::Str::regex::search ( std::string  s,
const std::string &  pattern,
const std::function< void(const std::smatch &)> &  callback,
std::regex_constants::match_flag_type  flags = std::regex_constants::match_default 
)
static

Iterate over all substrings of s that match the pattern.

Parameters
sinput string
patternregular expression pattern
callbackcalled for each match
flags[optional] controls how pattern is matched
Returns
true if any match occurred

The documentation for this struct was generated from the following files: