3v4l.org

run code in 500+ PHP versions simultaneously
<?php $text = 'advcd<img loading="lazy" class="abcd pqr" alt="chi-phi-sinh-o-benh-v"ien-dai-hoc-y-duoc-co-so-2" attr="val"><img loading="lazy" class="abcd pqr" alt="abcd-sinh-o-benh-"ien-dai-hoc-y-duoc-co-so-3">sdfs'; preg_match_all('/(alt)=(".*?"(?=\s*(?:[^\s=]+="|>)))/i', $text, $matches); if (count($matches) > 1) { print_r($matches); }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
Array ( [0] => Array ( [0] => alt="chi-phi-sinh-o-benh-v"ien-dai-hoc-y-duoc-co-so-2" [1] => alt="abcd-sinh-o-benh-"ien-dai-hoc-y-duoc-co-so-3" ) [1] => Array ( [0] => alt [1] => alt ) [2] => Array ( [0] => "chi-phi-sinh-o-benh-v"ien-dai-hoc-y-duoc-co-so-2" [1] => "abcd-sinh-o-benh-"ien-dai-hoc-y-duoc-co-so-3" ) )

preferences:
66.84 ms | 1350 KiB | 4 Q