Help with regular expressions
I do not speak English'm using a translator
I am trying to extract text from a string that contains HTML example: <div> text </ div> I want to remove the word text.
I managed to extract when not using search parameters, but when I try to apply this busquedad (. *?) Just not working.
#include <stdio.h>
#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main()
{
regex patron1("<div>(.*?)</div>");
string palabra1 = "<div>texto</div>";
smatch match1;
regex_match(palabra1, match1, patron1)
cout << match1 << endl;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <stdio.h>
#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main()
{
regex patron1("<div>(.*?)</div>");
string palabra1 = "<div>texto</div>";
smatch match1;
regex_match(palabra1, match1, patron1);
for(size_t K=0; K<match1.size(); ++K)
std::cout << match1[K] << '\n';
}
|
<div>texto</div>
texto |
Last edited on