Answer the question
In order to leave comments, you need to log in
How to find multiple occurrences in one string?
Suppose there is a line in which there are N links, I wrote a regular expression to search for links, it works.
Is it possible to somehow get by with one reg. expression and immediately extract all the addresses from the string?
Or is it necessary to write a loop here and until the line is over, start a new search from the previous position?
std::string str = "<html><body><a href=\"url1\">name link1</a><bla bla bla><a href=\"url2\">name link2</a></body></html>";
std::smatch res;
std::regex reg("(<a href=\")([\\w\\s]*)(\">)(.*)(</a>)");
std::regex_search(str, res, reg);
std::cout << res[2] << std::endl;
std::regex_search(str, res, reg);
std::cout << res[2] << std::endl;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question