3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strs = ["NLNL LL","LNLN LL LL","NNLL LL LL LL","LNLN LLL LL","LLNN LL LLL"]; foreach ($strs as $s) { echo "----------------------------\n$s\n"; if (preg_match('~(?:\s[A-Z]{2})+$~', $s, $match)) { print_r(explode(" ",trim($match[0]))); } if (preg_match_all('~(?:\G(?!\A)|(?=(?:\s[A-Z]{2})+$))\s\K[A-Z]{2}~', $s, $matches)) { print_r($matches[0]); } }

preferences:
60.8 ms | 408 KiB | 5 Q