I'm trying to use google's re2 consume() method, which takes an abseil string_view object (basically the same as std::string_view) and consumes matched characters. My problem is that consume() doesn't really provide any good ways to get the matched characters back. What is the best way to figure out what was removed?
My guess was:
*code moved bc discord dumb
#string_view shennanigans
6 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
string somestr;
string_view strv(somestr);
char* before = strv.at(1);
consume(strv,...)
char* after = strv.at(1);
//somehow extract part of string from before up to after
well, there is a Match function that gives you the matched characters 😛
but you could also just look at how much shorter the string view is after consuming the matched characters
something like
std::string_view before{somestr};
std::string_view after{before};
consume(after, ...);
auto match_length = before.size() - after.size();
std::string_view match = before.substr(0, match_length);