-1
、私は唯一の11_custom_io.pptをしたい私は、C++のhrefの値を取得したいが、私のコードはregexを使ってC++でhrefの値を取得するには?
#include <fstream>
#include <iostream>
#include <string>
#include <regex>
int main()
{
std::regex url("/.*(href=')(.*)('>)/");
std::string url_test = "hjsh.ppt";
std::ifstream file("in.txt");
if (!file.is_open())
{
std::cerr << "Failed to open file!\n";
return -1;
}
const std::string needle = "href";
while (std::getline(file, url_test))
{
if (url_test.find(needle) != std::string::npos)
{
if(regex_match(url_test, url)){}
std::cout << url_test << "\n";
}
}
}
望ましい結果を与えていない上記のコードは
<a href="11_custom_io.ppt">Ch11: Customizing I/O</a>
として行全体を印刷しますファイルの名前。 助けてください。
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454 #1732454 –