0

I have many lines such as this:

string s = "Some HTML with two <A HREF="links"> in one <A HREF="line">";

I need to use regular expressions to get the URLs in between the quotation marks, like this:

string all_links[] = {"links", "line"};

How would I go about doing this?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Arjun Vasudevan
  • 139
  • 1
  • 8
  • 4
    Maybe take a look at [std::sregex_iterator](http://en.cppreference.com/w/cpp/regex/regex_iterator). – Galik Dec 11 '17 at 03:57
  • If you could give us what you tried, we can help you to find where goes wrong. – mhs Dec 11 '17 at 03:57
  • You need an HTML parser to do this reliably. You do not want to do this with regular expressions. HTML seems stupid simple at first, but there's a lot of nuances and ambiguity that can prove increasingly frustrating, especially when you expose this code to real-world data where not everyone follows the rules. – tadman Dec 11 '17 at 04:00
  • This answer possibly helps. https://stackoverflow.com/questions/6109882/regex-match-all-characters-between-two-strings – mhs Dec 11 '17 at 04:18

1 Answers1

0

As per your given string sample. Use [^\HREF="]+(?=">)

Demo

MUT
  • 576
  • 3
  • 18