1

I would like to match multiple results on a single line string but I am only able to get the last iteration on the result I excpected.

For example I have this string : <ul><li><a href="#">test1</a></li><li><a href="#">test2</a></li><a href="#">test3</a></li></ul>

I would like to get :

test1
test2
test3

As result but I only get "test3"

I used this regex <ul>(<li><a.*>(.*)<\/a><\/li>)*<\/ul> on : https://regex101.com/ but I don't know what I did wrong.

Alther
  • 31
  • 4
  • `preg_match_all` http://php.net/manual/en/function.preg-match-all.php – pokeybit Sep 23 '17 at 10:34
  • Well, the pattern is wrong. Not each `
  • ` is enclosed by an `
      `. You'll have to use two regexps for context/simplicity. While unversed use a DOM traversal frontend: `qphtml($html, "ul li")`
  • – mario Sep 23 '17 at 10:35
  • @mario: I guess that's just an error in the question description. – Jan Sep 23 '17 at 17:46