17#include <zypp-core/base/Regex.h>
18#include <zypp-core/base/StringV.h>
24: m_flags( match_extended )
45 static constexpr int normal = 1<<16;
46 if ( flags & normal ) flags &= ~normal;
49 if (
int err = regcomp( &
m_preg,
str.c_str(), flags ) ) {
51 regerror( err, &
m_preg, errbuff,
sizeof(errbuff) );
60 const auto possibleMatchCount =
m_preg.re_nsub + 1;
61 matches.pmatch.resize( possibleMatchCount );
62 memset(
matches.pmatch.data(), -1,
sizeof( regmatch_t ) * ( possibleMatchCount ) );
98{
return( i <
pmatch.size() &&
pmatch[i].rm_so != -1 ?
pmatch[i].rm_so : std::string::npos ); }
101{
return( i <
pmatch.size() &&
pmatch[i].rm_so != -1 ?
pmatch[i].rm_eo : std::string::npos ); }
108 unsigned matches = unsigned(-1);
112 for (
unsigned i = 0; i <
pmatch.size(); ++i )
114 if (
pmatch[i].rm_so != -1 )
123 strv::splitRx( s,
regex, [&result,&replacement,global]( std::string_view w,
unsigned,
bool last ) {
126 result += replacement;
@ rxdefault
These are enforced even if you don't pass them as flag argument.
void assign(const std::string &s, int flags)
bool matches(const char *s, str::smatch &matches, int flags=none) const
Regular expression match result.
std::string::size_type end(unsigned i) const
End index of subexpression i in match_str (or std::string::npos)
std::string::size_type begin(unsigned i) const
Begin index of subexpression i in match_str (or std::string::npos)
std::string operator[](unsigned i) const
std::vector< regmatch_t > pmatch
String related utilities and Regular expression matching.
String related utilities and Regular expression matching.
std::string regex_substitute(const std::string &s, const regex ®ex, const std::string &replacement, bool global=true)
Replaces the matched regex with the string passed in replacement.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Easy-to use interface to the ZYPP dependency resolver.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.