我有一些行
wstring const html = LR"(
<td><a href="4.%20Functions,%20scope.ppt">4. Functions, scope.ppt</a></td>
<td><a href="4.%20Functions,%20scope.ppt">4. Functions, scope.ppt</a></td>
<td><a href="4.%20Functions,%20scope.ppt">4. Functions, scope.ppt</a></td>
)";
// for convenience
const auto fast_n_loose = regex_constants::optimize | regex_constants::icase;
//icase: without case
//optimize: priority matching efficient
// extract href's
wregex const link{ LR"~(href=(["'])(.*?)\1)~", fast_n_loose };
int main()
{
// regex iterators
string s (html.begin(), html.end());
wsregex_iterator itr_end;
wsregex_iterator itr{ begin(html), end(html), link };
// iterate through the matches
for (; itr != itr_end; itr++)
{
wcout << itr->str(2) << '\n';
}
}
我尝试将wstring转换为字符串,但会犯很多错误。也许我对使用迭代器的一些结构错了。 我该怎么编辑?