<?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]);
}
}
- Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- ----------------------------
NLNL LL
Array
(
[0] => LL
)
Array
(
[0] => LL
)
----------------------------
LNLN LL LL
Array
(
[0] => LL
[1] => LL
)
Array
(
[0] => LL
[1] => LL
)
----------------------------
NNLL LL LL LL
Array
(
[0] => LL
[1] => LL
[2] => LL
)
Array
(
[0] => LL
[1] => LL
[2] => LL
)
----------------------------
LNLN LLL LL
Array
(
[0] => LL
)
Array
(
[0] => LL
)
----------------------------
LLNN LL LLL
preferences:
76.89 ms | 408 KiB | 5 Q