I'm using curl to get an HTML document. From this document, I want to get the name & value of any input field.
However, after many tries, my C++ regex still doesn't work and I'm starting to loose hope.
I'm using the default c++11 regex which use the ECMAScript syntax
Here's my code
void regexFind(std::string &str)
{
std::string regex = "value=\"(.*)\"";
std::smatch m;
std::regex e(regex);
if (std::regex_search(str, m, e))
{
std::cout << m[0] << std::endl;
}
else
std::cout << "No match" << std::endl;
}
void htmlRegexTest()
{
std::string str;
str = "<div><input name=\"somteTest\" type=\"hidden\" value=\"✓\" /></div>";
regexFind(str);
}
So basically, I've tried many many regexp but couldn't match anything.
I'm not sure that regexp is the better solution for this problem so if you have a better solution than regex it would be also great.
Thanks in advance for your help.
-- Edit --
Okay, so it seems that using regex to parse HTML is a bad solution. So change my question a little, what is the best solution (aka easiest) to parse HTML in c++ ?