12#ifndef ZYPP_BASE_REGEX_H
13#define ZYPP_BASE_REGEX_H
19#include <zypp-core/base/Exception.h>
67 bool regex_match(
const char * s, smatch & matches,
const regex & regex );
70 inline bool regex_match(
const std::string & s, smatch & matches,
const regex & regex)
71 {
return regex_match( s.c_str(), matches, regex ); }
74 bool regex_match(
const char * s,
const regex & regex );
77 inline bool regex_match(
const std::string & s,
const regex & regex )
86 std::string
regex_substitute (
const std::string & s,
const regex & regex,
const std::string &replacement,
bool global =
true );
117 {
assign( rhs.m_str, rhs.m_flags ); }
120 {
assign( rhs.m_str, rhs.m_flags );
return *
this; }
129 bool matches(
const std::string & s_r, str::smatch & matches_r,
int flags_r =
none )
const
130 {
return matches( s_r.c_str(), matches_r, flags_r ); }
132 bool matches(
const char * s )
const;
133 bool matches(
const std::string & s_r )
const
134 {
return matches( s_r.c_str() ); }
142 void assign(
const std::string & s,
int flags );
153 inline std::ostream &
operator<<( std::ostream &
str,
const regex & obj )
154 {
return str << obj.asString(); }
174 unsigned size()
const;
177 std::string::size_type
begin(
unsigned i )
const;
180 std::string::size_type
end(
unsigned i )
const;
183 std::string::size_type
size(
unsigned i )
const;
186 std::vector<regmatch_t>
pmatch;
regex_t * get()
Expert backdoor.
@ match_extended
Use POSIX Extended Regular Expression syntax when interpreting regex.
@ icase
Do not differentiate case.
@ rxdefault
These are enforced even if you don't pass them as flag argument.
@ nosubs
Support for substring addressing of matches is not required.
std::string asString() const
string representation of the regular expression
void assign(const std::string &s, int flags)
bool matches(const char *s, str::smatch &matches, int flags=none) const
@ not_bol
Do not match begin of line.
regex & operator=(const regex &rhs)
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.
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.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)