本文整理汇总了C++中rxx::len方法的典型用法代码示例。如果您正苦于以下问题:C++ rxx::len方法的具体用法?C++ rxx::len怎么用?C++ rxx::len使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxx
的用法示例。
在下文中一共展示了rxx::len方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: path
int
main (int argc, const char *argv[])
{
if (argc < 2)
return -1;
str parent, filename;
parentpath (parent, filename, str (argv[1]));
warn << parent << "\n";
warn << filename << "\n";
return 0;
vec<str> out;
splitpath (out, argv[1]);
str foo;
while (out.size () > 0 && (foo = out.pop_front ()))
warn << foo << "\n";
return 0;
str path (argv[1]);
// vec<str> out;
static rxx r ("^(.*)/([^/]+)$");
// static rxx r ("^/*([^/]+)(/.*)?$");
// static rxx r ("^s%/[^/]*$%%");
// static rxx pathsplit ("^/*([^/]+)(/.*)?$");
warn << "path: " << path << "\n";
// path = path/r;
if (r.search (path))
{
if (r.len(1) != -1)
warn << r[1] << " -> ";
if (r.len(2) != -1)
warn << r[2] << "\n";
warn << "r[0]: " << r[0] << "\n";
}
warn << split (&out, "/", path) << "\n";
for (unsigned int i=0; i< out.size(); i++)
warn << out[i] << "\n";
return 0;
}
示例2: sep
// A lot of this is taken from async/rxx.C in sfslite, but with some
// modifications for returning the matched pattern.
//
int
split2 (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)));
str sep (p + pat.start (0), pat.len (0));
out->push_back (sep);
}
p += max (pat.end (0), 1);
}
if (lim && (p < e || emptylast)) {
n++;
if (out) {
out->push_back (str (p, e - p));
}
}
return n;
}
示例3: str
void
repl_el_capture_t::output (strbuf &out, const char *s, rxx &x)
{
int start = x.start (_i);
int ln = x.len (_i);
if (start >= 0 && ln > 0) {
str repl = str (s + start, ln);
strbuf_output (out, repl);
}
}
示例4: if
static void
extract_matches (vec<str> *out, const char *base, rxx &x)
{
bool go = true;
for (int i = 0; go; i++) {
int ln = x.len (i);
int start = x.start (i);
if (ln < 0 || start < 0) { go = false; }
else if (ln > 0) { out->push_back (str (base + start, ln)); }
}
}