3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input_lines = [ "abc-def/something/else/ [incl. slash if there is not character before it]", "abc-def-2019/something/else/", "abc-def-2019-2020/something/else/", "abc-def-125-2019/something/else/", "aaa-20199-2019/", "aaa", "aaa/", "aaa2019", "aaa2019test/", "aaa201aaa2019aaa2019/" ]; $pattern = '~^(?=[a-z\d-]*/)[a-zA-Z013-9-]+(?>2(?!0(?:19|20)(?!\d))|[a-zA-Z013-9-]+)*/?~'; foreach ($input_lines as $input_line) { echo preg_replace($pattern, '', $input_line) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/HNTle
function name:  (null)
number of ops:  14
compiled vars:  !0 = $input_lines, !1 = $pattern, !2 = $input_line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   16     1        ASSIGN                                                   !1, '%7E%5E%28%3F%3D%5Ba-z%5Cd-%5D%2A%2F%29%5Ba-zA-Z013-9-%5D%2B%28%3F%3E2%28%3F%210%28%3F%3A19%7C20%29%28%3F%21%5Cd%29%29%7C%5Ba-zA-Z013-9-%5D%2B%29%2A%2F%3F%7E'
   17     2      > FE_RESET_R                                       $5      !0, ->12
          3    > > FE_FETCH_R                                               $5, !2, ->12
   18     4    >   INIT_FCALL                                               'preg_replace'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 ''
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~7      $6, '%0A'
         10        ECHO                                                     ~7
   17    11      > JMP                                                      ->3
         12    >   FE_FREE                                                  $5
   19    13      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.97 ms | 1004 KiB | 14 Q