mardi 23 juin 2015

C++ regex - get a link from html code

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <regex>

using namespace std;

int main(int argc, char* argv[]) {

     string test = "<html><div><script>var link = "http://ift.tt/1JgjeKA";</script></div></html>";

     regex re("http://example.com/(*)");
     smatch match;

     if (regex_search(test, match, re)) {

     cout<<"OK"<<endl;

     }

     return 0;
}

The command for this compile.

root# g++ test.cpp -o test -std=gnu++11

This program not working. How do I get the link (use regex) from the html code? Please, help me.

Aucun commentaire:

Enregistrer un commentaire