-1

I have made a HTML Get request, I want to parse the result.

For example, I have a line :

<span class="lm3_eq1">Energetyk-BGU Res.<span class="hidden-xs"><img src="/image/logo/club/16/equipe-logodefaut.png" width="16" height="16" alt="Energetyk-BGU Res."></span></span><span class="lm3_score" id="score_3282826">0 - 1</span><span class="lm3_eq2"><span class="hidden-xs"><img src="/image/logo/club/16/equipe-logodefaut.png" width="16" height="16" alt="FK Ruh Brest Res."></span>FK Ruh Brest Res.</span>

I want to have the following result :

  • Energetyk-BGU Res.
  • 0 - 1
  • FK Ruh Brest Res.

I'm not an expert with regex

I have tried this but this doesn't work :

(?<=>)(.*)(?=<)

The result is

"Energetyk-BGU Res.<span class="hidden-xs"><img src="/image/logo/club/16/equipe-logodefaut.png" width="16" height="16" alt="Energetyk-BGU Res."></span></span><span class="lm3_score" id="score_3282826">0 - 1</span><span class="lm3_eq2"><span class="hidden-xs"><img src="/image/logo/club/16/equipe-logodefaut.png" width="16" height="16" alt="FK Ruh Brest Res."></span>FK Ruh Brest Res."

Thanks

mm98
  • 409
  • 1
  • 6
  • 18
  • which language are you using? some languages don't support some regex function, that's why i am asking – Alberto Sinigaglia Jul 11 '20 at 11:59
  • 3
    [Parsing HTML with regex is a hard job](https://stackoverflow.com/a/4234491/372239) HTML and regex are not good friends. Use a parser, it is simpler, faster and much more maintainable. – Toto Jul 11 '20 at 12:00
  • @Berto99 I develop in c++11 – mm98 Jul 11 '20 at 12:12
  • One way is to use a language that supports split. I've simulated a split with the two regex's below. If using C++11, do a regex replace as in my examples, then do another regex search using `[^\n]+` which will return all the non-tagged text. –  Jul 11 '20 at 20:53

1 Answers1

-2

You have to use (.*?). Look up lazy vs greedy quantifiers.

Hielke Walinga
  • 2,677
  • 1
  • 17
  • 30