regex - C++ regular expression over a stream -
i have large text file (up few hundred mb) process stl regular expression. matching region looking spans several lines , happens @ least few thousand times in file.
can use stream iterators purpose? i've tried std::istream_iterator, no luck. 1 post minimal working example?
note, looking solution involving stl. in perfect solution iterate on matches.
edit
once i've read comment, understand not possible. maybe there way iterate on regex matches found in large text file:
#include <regex> #include <iostream> #include <string> const std::string s = r"(quick brown fox jumps on several lines)"; // @ least 200mb of multiline text here int main(int argc,char* argv[]) { std::regex find_jumping_fox("(quick(?:.|\\n)+?jump\\s*?)"); auto = std::sregex_iterator(s.begin(), s.end(), find_jumping_fox); (std::sregex_iterator = it; != std::sregex_iterator(); ++i) { std::smatch match = *i; std::string match_str = match.str(); std::cout << match_str << '\n'; } }
Comments
Post a Comment