本文整理汇总了C++中rxx::_exec方法的典型用法代码示例。如果您正苦于以下问题:C++ rxx::_exec方法的具体用法?C++ rxx::_exec怎么用?C++ rxx::_exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxx
的用法示例。
在下文中一共展示了rxx::_exec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: max
int
split (vec<str> *out, rxx pat, str expr, size_t lim, bool emptylast)
{
const char *p = expr;
const char *const e = p + expr.len ();
size_t n;
if (out)
out->clear ();
// check p < e to see that we're not dealing with an empty
// string (especially since x? matches "").
for (n = 0; p < e && n + 1 < lim; n++) {
if (!pat._exec (p, e - p, 0)) {
return 0;
}
if (!pat.success ())
break;
if (out)
out->push_back (str (p, pat.start (0)));
p += max (pat.end (0), 1);
}
if (lim && (p < e || emptylast)) {
n++;
if (out) {
out->push_back (str (p, e - p));
}
}
return n;
}
示例2: if
str
rxx_replace_2 (str input, rxx pat, str repl_str)
{
repl_t repl;
str ret;
if (!repl.parse (repl_str)) {
warn << "XX cannot parse replacement string: " << repl_str << "\n";
} else {
const char *p = input;
const char *const e = p + input.len ();
strbuf b;
bool go = true;
bool err = false;
// check p < e to see that we're not dealing with an empty
// string (especially since x? matches "").
while (go && !err && p < e) {
if (!pat._exec (p, e - p, 0)) {
warn << "XX regex execution failed\n";
err = true;
}
else if (!pat.success ()) { go = false; }
else {
str pre = str (p, pat.start (0));
strbuf_output (b, pre);
repl.output (b, p, pat);
p += max (pat.end (0), 1);
}
}
if (p < e && !err) {
str post = str (p, e - p);
strbuf_output (b, post);
}
if (!err) { ret = b; }
}
return ret;
}