0
我正在尋找一個特定字符的第一次出現相匹配的解決方案的第一次出現,說「<」的標誌:升壓regex_search - 匹配到一個字符
這是我的代碼:
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);
}
我希望sResult是 「8.36」,而是它包含這個字符串: 「每月7.99」 「cartContent」:{ 「HTML」: 「」
感謝你的幫助。
作品,謝謝! – robert