I'm looking for a solution that matches the first occurrence of a specific character, say a "<" sign:
This is my code:
std::string sRegex("a-color-price'.*\\$(.*?)<");
boost::regex regex(sRegex, boost::regex::icase);
std::string sStr("<span class='a-color-price'>$8.36</span></div> $7.99 per month\" \"cartContent\":{\"html\":\"<div id='nav-cart-flyout' </sdd>");
boost::cmatch result;
if (boost::regex_search(sStr.c_str(), result, regex))
{
std::string sResult(result[1].first, result[1].second);
}
I expect sResult to be "8.36" and instead it contains this string: "7.99 per month" "cartContent":{"html":""
Appreciate your help.