bool capture(const std::string& re, std::string& src) { std::string pat, flags; pcrecpp::RE rx("^\\/(.*)\\/(.*)$", pcrecpp::UTF8()); if (rx.PartialMatch(re, &pat, &flags)) { if (src.empty()) // Check regexp return true; pcrecpp::RE_Options opts = _init_re_opts(flags); if (strstr(flags.c_str(), "g") != 0) { std::string orig(src); pcrecpp::StringPiece sp(orig); pcrecpp::RE re(pat, opts); _check_re_error(re); src.clear(); std::string s; while (re.FindAndConsume(&sp, &s)) src += s; } else { std::string tmp = src; src.clear(); pcrecpp::RE re(pat, opts); _check_re_error(re); re.PartialMatch(tmp, &src); } return true; } return false; }