doxygen
Classes | Functions
reg Namespace Reference

Namespace for the regular expression functions. More...

Classes

class  Ex
 Class representing a regular expression. More...
 
class  Iterator
 Iterator class to iterator through matches. More...
 
class  Match
 Object representing the matching results. More...
 
class  PToken
 Class representing a token in the compiled regular expression token stream. More...
 
class  SubMatch
 Object representing the match results of a capture range. More...
 

Functions

bool search (std::string_view str, Match &match, const Ex &re, size_t pos=0)
 Search in a given string str starting at position pos for a match against regular expression re. More...
 
bool search (std::string_view str, const Ex &re, size_t pos=0)
 Search in a given string str starting at position pos for a match against regular expression re. More...
 
bool match (std::string_view str, Match &match, const Ex &re)
 Matches a given string str for a match against regular expression re. More...
 
bool match (std::string_view str, const Ex &re)
 Matches a given string str for a match against regular expression re. More...
 
std::string replace (std::string_view str, const Ex &re, std::string_view replacement)
 Searching in a given input string for parts that match regular expression re and replaces those parts by string replacement.
 

Detailed Description

Namespace for the regular expression functions.

Function Documentation

◆ match() [1/2]

bool reg::match ( std::string_view  str,
Match match,
const Ex re 
)

Matches a given string str for a match against regular expression re.

Returns true iff a match was found for the whole string. Any capture groups are returned via the match object.

◆ match() [2/2]

bool reg::match ( std::string_view  str,
const Ex re 
)

Matches a given string str for a match against regular expression re.

Returns true iff a match was found for the whole string.

◆ search() [1/2]

bool reg::search ( std::string_view  str,
Match match,
const Ex re,
size_t  pos = 0 
)

Search in a given string str starting at position pos for a match against regular expression re.

Returns true iff a match was found. Details of what part of the string has matched is returned via the match object.

An example to show how to match all identifiers in a string.

static reg::Ex re(R"(\a\w*)");
std::string = u8"void(Func是<B_C::Códe42>(42));";
while (reg::search(str,match,re,pos))
{
std::cout << match.str() << std::endl;
pos=match.position()+match.length();
}

produces:

void
Func是
B_C
Códe42
See also
Ex::Ex() for details on the regular expression patterns.

◆ search() [2/2]

bool reg::search ( std::string_view  str,
const Ex re,
size_t  pos = 0 
)

Search in a given string str starting at position pos for a match against regular expression re.

Returns true iff a match was found.