24 #include "jubatus/util/lang/cast.h"
27 using jubatus::util::lang::lexical_cast;
32 namespace fv_converter {
39 "'group' must be positive: " + lexical_cast<std::string>(group)));
45 if (group >
re_.NumberOfCapturingGroups()) {
46 std::string msg =
"regexp '" + regexp +
"' only contains "
47 + lexical_cast<std::string>(
re_.NumberOfCapturingGroups())
48 +
" groups, but 'group' is " + lexical_cast<std::string>(group);
54 const std::string& str,
55 std::vector<std::pair<size_t, size_t> >& bounds)
const {
56 re2::StringPiece input(str.c_str());
57 int groupSize =
re_.NumberOfCapturingGroups() + 1;
58 std::vector<re2::StringPiece> words(groupSize);
60 while (
re_.Match(input, current, input.size(), re2::RE2::UNANCHORED,
61 &(words[0]), words.size())) {
62 size_t len = words[
group_].length();
63 size_t pos = words[
group_].begin() - input.begin();
64 bounds.push_back(std::make_pair(pos, len));
66 size_t next = words[
group_].end() - input.begin();
67 if (current == next) {
regexp_splitter(const std::string ®exp, int group)
#define JUBATUS_EXCEPTION(e)
void split(const std::string &str, std::vector< std::pair< size_t, size_t > > &bounds) const