I have a text in form of:
Txx8xxTT<br><br><br>https://wwww.xxx.com<br><br />
<br />cxyc[link=http://www.example.com]link[/odkaz]
xxx<a href="http://www.example2.com">link2</a>
I want to parse this using preg_match_all where in the result array all standalone links are at separate indices. In the example case I want to have something like this:
[0] => Txx8xxTT<br><br><br>
[1] => https://wwww.xxx.com
[2] => <br><br />
<br />cxyc[link=http://www.example.com]link[/odkaz]
xxx<a href="http://www.example2.com">link2</a>
(The array can be formatted differently, I dont care about the indices, but I want the separate links at its own index)
I have tried to use preg_match_all
with (.[^ \<\[]*)
. It almost works, but I get the result at index [3] as <br>https://wwww.xxx.com
, where I dont want the <br>
prefix.
[0] => Txx8xxTT
[1] => <br>
[2] => <br>
[3] => <br>https://wwww.xxx.com
[4] => <br>
[5] => <br
[6] => />
[7] => <br
[8] => />cxyc
[9] => [link="http://www.example.com"]link
[10] => [/odkaz]xxx
[11] => <a
[12] => href="http://www.example2.com">link2
[13] => </a>