3v4l.org

run code in 500+ 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 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/HNTle
function name:  (null)
number of ops:  11
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, ->9
          3    > > FE_FETCH_R                                                   $5, !2, ->9
   18     4    >   FRAMELESS_ICALL_3                preg_replace        ~6      !1, ''
          5        OP_DATA                                                      !2
          6        CONCAT                                               ~7      ~6, '%0A'
          7        ECHO                                                         ~7
   17     8      > JMP                                                          ->3
          9    >   FE_FREE                                                      $5
   19    10      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.6 ms | 2259 KiB | 13 Q