I am using regex to retrieve a string from between divs in a html page however I have run into a out of memory error. I am using Visual Studio 2012 and C++.
The regex expression is "class=\"ListingDescription\">((.*|\r|\n)*?(?=</div>))"
and regxbuddy reckons it does it in 242 steps (much better than ~5000 it had originally). The website I am trying to scrap the info from is http://www.trademe.co.nz/Browse/Listing.aspx?id=557211466
Here is the code:
typedef match_results<const char*> cmatch;
tr1::cmatch results;
try {
tr1::regex regx("class=\"ListingDescription\">((.*|\\r|\\n)*?(?=</div>))");
tr1::regex_search(data.c_str(), results, regx);
cout << result[1];
}
catch (const std::regex_error& e) {
std::cout << "regex_error caught: " << e.what() << '\n';
if (e.code() == std::regex_constants::error_brack) {
std::cout << "The code was error_brack\n";
}
}
This is the error I get:
regex_error caught: regex_error(error_stack): There was insufficient memory to d
etermine whether the regular expression could match the specified character sequ
ence.
Regexbuddy works fine and so do some online regex tools just not my code :( Please help