23 : m_flags(match_extended)
36 static const int normal = 1<<16;
37 if (!(flags & normal)) {
42 if ((err = regcomp(&
m_preg,
str.c_str(), flags))) {
44 regerror(err, &
m_preg, errbuff,
sizeof(errbuff));
62 const auto possibleMatchCount =
m_preg.re_nsub + 1;
63 matches.pmatch.resize( possibleMatchCount );
64 memset(
matches.pmatch.data(), -1,
sizeof( regmatch_t ) * ( possibleMatchCount ) );
74 return s && !regexec(&
m_preg, s, 0, NULL, 0);
99 {
return( i <
pmatch.size() &&
pmatch[i].rm_so != -1 ?
pmatch[i].rm_so : std::string::npos ); }
102 {
return( i <
pmatch.size() &&
pmatch[i].rm_so != -1 ?
pmatch[i].rm_eo : std::string::npos ); }
109 unsigned matches = unsigned(-1);
113 for (
unsigned i = 0; i <
pmatch.size(); ++i )
115 if (
pmatch[i].rm_so != -1 )
134 if ( match.size() ) {
135 result += s.substr( off, match.begin(0) );
136 result += replacement;
137 off = match.
end(0) + off;
145 if ( off > 0 && off < s.size() && s[ off - 1 ] ==
'\n' )
151 result += s.substr( off );
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.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
String related utilities and Regular expression matching.
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)
Do not match begin of line.
String related utilities and Regular expression matching.
bool matches(const char *s, str::smatch &matches, int flags=none) const
Regular expression match result.
Use POSIX Extended Regular Expression syntax when interpreting regex.
void assign(const std::string &s, int flags=match_extended)
std::string operator[](unsigned i) const
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
regex ZYPP_STR_REGEX regex ZYPP_STR_REGEX
std::vector< regmatch_t > pmatch
Easy-to use interface to the ZYPP dependency resolver.