I'm using preg_match_all() like this:
preg_match_all('/("user":"(.*?)".*?-->)/', $input_lines, $output_array);
On a string, the idea is that I want it to get whatever comes after "user" in a commented out block (it's a long story). So let's say $input_lines is something like:
<!-- block {"user":"josh-hart", 1234566 ,"hide":false} /-->
<!-- block {"user":"jalen-brunson", 7744633 ,"hide":true} /-->
<!-- block {"user":"julius-randle", 333333,"hide":false} /-->
<!-- block {"user":"obi-toppin", 4hh3n33n33n, /-->
<!-- block {"user":"rj-barrett", nmremxxx!! ,"hide":true} /-->
<!-- block {"user":"mitch-robinson",yahaoao /-->
I want it to match the user. But here's the the thing, I only want the user if "hide":true
does not appear before the /-->
. So for this string I would want the matches to be:
josh-hart, julius-randle, obi-toppin, mitch-robinson
What is this called in regex terms and how do i do it?