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]); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 35
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 35
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 34
Branch analysis from position: 24
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/aTo3V
function name:  (null)
number of ops:  37
compiled vars:  !0 = $strs, !1 = $s, !2 = $match, !3 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1      > FE_RESET_R                                       $5      !0, ->35
          2    > > FE_FETCH_R                                               $5, !1, ->35
    5     3    >   ROPE_INIT                                     3  ~7      '----------------------------%0A'
          4        ROPE_ADD                                      1  ~7      ~7, !1
          5        ROPE_END                                      2  ~6      ~7, '%0A'
          6        ECHO                                                     ~6
    6     7        INIT_FCALL                                               'preg_match'
          8        SEND_VAL                                                 '%7E%28%3F%3A%5Cs%5BA-Z%5D%7B2%7D%29%2B%24%7E'
          9        SEND_VAR                                                 !1
         10        SEND_REF                                                 !2
         11        DO_ICALL                                         $9      
         12      > JMPZ                                                     $9, ->24
    7    13    >   INIT_FCALL                                               'print_r'
         14        INIT_FCALL                                               'explode'
         15        SEND_VAL                                                 '+'
         16        INIT_FCALL                                               'trim'
         17        FETCH_DIM_R                                      ~10     !2, 0
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                         $11     
         20        SEND_VAR                                                 $11
         21        DO_ICALL                                         $12     
         22        SEND_VAR                                                 $12
         23        DO_ICALL                                                 
    9    24    >   INIT_FCALL                                               'preg_match_all'
         25        SEND_VAL                                                 '%7E%28%3F%3A%5CG%28%3F%21%5CA%29%7C%28%3F%3D%28%3F%3A%5Cs%5BA-Z%5D%7B2%7D%29%2B%24%29%29%5Cs%5CK%5BA-Z%5D%7B2%7D%7E'
         26        SEND_VAR                                                 !1
         27        SEND_REF                                                 !3
         28        DO_ICALL                                         $14     
         29      > JMPZ                                                     $14, ->34
   10    30    >   INIT_FCALL                                               'print_r'
         31        FETCH_DIM_R                                      ~15     !3, 0
         32        SEND_VAL                                                 ~15
         33        DO_ICALL                                                 
    4    34    > > JMP                                                      ->2
         35    >   FE_FREE                                                  $5
   13    36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.77 ms | 1446 KiB | 18 Q