libzypp 17.31.0
Regular expression matching

Regular expressions using the glibc regex library. More...


class  zypp::str::regex
 Regular expression. More...
class  zypp::str::smatch
 Regular expression match result. More...


bool regex_match (const char *s, smatch &matches, const regex &regex)
 Regular expression matching. More...

Detailed Description

Regular expressions using the glibc regex library.

See also
also StrMatcher string matcher also supporting globing, etc.
str::regex rxexpr( "^(A)?([0-9]*) im" );
std::string mytext( "Y123 imXXXX" );
if ( str::regex_match( mytext, what, rxexpr ) )
MIL << "MATCH '" << what[0] << "'" << endl;
MIL << " subs: " << what.size()-1 << endl;
for_( i, 1U, what.size() )
MIL << " [" << i << "] " << what[i] << endl;
WAR << "NO MATCH '" << rxexpr << "' in '" << mytext << endl;
Regular expression.
Definition: Regex.h:95
Regular expression match result.
Definition: Regex.h:168
unsigned size() const
bool regex_match(const std::string &s, smatch &matches, const regex &regex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Definition: Regex.h:70
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
#define MIL
Definition: Logger.h:96
#define WAR
Definition: Logger.h:97

Function Documentation

◆ regex_match()

bool regex_match ( const char *  s,
smatch matches,
const regex regex 

Regular expression matching.

Return whether a regex matches a specific string. An optionally passed smatch object will contain the match reults.