3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regex = <<<REGEX ~ ^ # start of string anchor (CONF|ESD|TRACKING) # start capture group 1 KEY, three literal words (?: # start non-capturing group 1 \h*[:;'\h]\h* # require a listed punctuation or space with optional leading or trailing spaces (\S+(?:\h+\S+)*?) # start capture group 2 LINE, require one or more non-whitespace characters then lazily match zero or more repetitions of whitespace then non-whitespace substrings (?: # start non-capturing group 2 \h*L\h*[:;'\h]\h* # require literal L then a listed punctuation or space with optional leading or trailing spaces ( # start capture group 3 LINE_DATA (?:\d+(?:\(\d+\))?) # require a number optionally followed by another number in parentheses (?:\h*,\h*\d+(?:\(\d+\))?)* # optionally match zero or more repetitions of the previous expression if separated by an optionally space-padded comma ) # end capture group 3 and make it optional )? # end non-capturing group 2 (?: # start non-capturing group 3 \h* # match zero or more whitespaces ( # start capture group 4 INITIALS \*[.a-z]+ # match literal asterisk, then one or more dots and letters ) # end capture group 4 )? # end non-capturing group 3 and make it optional )? # end non-capturing group 2 and make it optional \h* # allow trailing whitespaces $ # end of string anchor ~ix REGEX; $tests = [ "esd hedf L:1,2,3 *sm ", "CONF: FEDEX 12345 L: 12(2),2(9),32 *SM", "Tracking *cool", "ESD: 12/12/92 L: ", "tRacking' my data L: 1,2,3(4) ", "conf something *asterisk", "tracking", "ConF''' something '' L: 6", "esd test 24(7)", ]; foreach ($tests as $i => $test) { if (preg_match($regex, $test, $m, PREG_UNMATCHED_AS_NULL)) { var_export([ "test index" => $i, "KEY" => $m[1], "LINE" => $m[2] ?? null, "LINE_DATA" => $m[3] ?? null, "INITIALS" => $m[4] ?? null ]); echo "\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 32
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 31
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/NUl0U
function name:  (null)
number of ops:  34
compiled vars:  !0 = $regex, !1 = $tests, !2 = $test, !3 = $i, !4 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7E%0A%5E++++++++++++++++++++++++++++++++++%23+start+of+string+anchor%0A%28CONF%7CESD%7CTRACKING%29++++++++++++++++%23+start+capture+group+1+KEY%2C+three+literal+words%0A%28%3F%3A++++++++++++++++++++++++++++++++%23+start+non-capturing+group+1%0A++%5Ch%2A%5B%3A%3B%27%5Ch%5D%5Ch%2A++++++++++++++++++++%23+require+a+listed+punctuation+or+space+with+optional+leading+or+trailing+spaces+%0A++%28%5CS%2B%28%3F%3A%5Ch%2B%5CS%2B%29%2A%3F%29++++++++++++++++%23+start+capture+group+2+LINE%2C+require+one+or+more+non-whitespace+characters+then+lazily+match+zero+or+more+repetitions+of+whitespace+then+non-whitespace+substrings%0A++%28%3F%3A++++++++++++++++++++++++++++++%23+start+non-capturing+group+2%0A++++%5Ch%2AL%5Ch%2A%5B%3A%3B%27%5Ch%5D%5Ch%2A++++++++++++++%23+require+literal+L+then+a+listed+punctuation+or+space+with+optional+leading+or+trailing+spaces%0A++++%28++++++++++++++++++++++++++++++%23+start+capture+group+3+LINE_DATA%0A++++++%28%3F%3A%5Cd%2B%28%3F%3A%5C%28%5Cd%2B%5C%29%29%3F%29++++++++++%23+require+a+number+optionally+followed+by+another+number+in+parentheses%0A++++++%28%3F%3A%5Ch%2A%2C%5Ch%2A%5Cd%2B%28%3F%3A%5C%28%5Cd%2B%5C%29%29%3F%29%2A++%23+optionally+match+zero+or+more+repetitions+of+the+previous+expression+if+separated+by+an+optionally+space-padded+comma%0A++++%29++++++++++++++++++++++++++++++%23+end+capture+group+3+and+make+it+optional%0A++%29%3F+++++++++++++++++++++++++++++++%23+end+non-capturing+group+2%0A++%28%3F%3A++++++++++++++++++++++++++++++%23+start+non-capturing+group+3%0A++++%5Ch%2A++++++++++++++++++++++++++++%23+match+zero+or+more+whitespaces%0A++++%28++++++++++++++++++++++++++++++%23+start+capture+group+4+INITIALS%0A++++++%5C%2A%5B.a-z%5D%2B++++++++++++++++++++%23+match+literal+asterisk%2C+then+one+or+more+dots+and+letters%0A++++%29++++++++++++++++++++++++++++++%23+end+capture+group+4%0A++%29%3F+++++++++++++++++++++++++++++++%23+end+non-capturing+group+3+and+make+it+optional%0A%29%3F+++++++++++++++++++++++++++++++++%23+end+non-capturing+group+2+and+make+it+optional%0A%5Ch%2A++++++++++++++++++++++++++++++++%23+allow+trailing+whitespaces+%0A%24++++++++++++++++++++++++++++++++++%23+end+of+string+anchor%0A%7Eix'
   29     1        ASSIGN                                                   !1, <array>
   41     2      > FE_RESET_R                                       $7      !1, ->32
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->32
          4    >   ASSIGN                                                   !3, ~8
   42     5        INIT_FCALL                                               'preg_match'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !2
          8        SEND_REF                                                 !4
          9        SEND_VAL                                                 512
         10        DO_ICALL                                         $10     
         11      > JMPZ                                                     $10, ->31
   43    12    >   INIT_FCALL                                               'var_export'
   44    13        INIT_ARRAY                                       ~11     !3, 'test+index'
   45    14        FETCH_DIM_R                                      ~12     !4, 1
         15        ADD_ARRAY_ELEMENT                                ~11     ~12, 'KEY'
   46    16        FETCH_DIM_IS                                     ~13     !4, 2
         17        COALESCE                                         ~14     ~13
   44    18        QM_ASSIGN                                        ~14     null
         19        ADD_ARRAY_ELEMENT                                ~11     ~14, 'LINE'
   47    20        FETCH_DIM_IS                                     ~15     !4, 3
         21        COALESCE                                         ~16     ~15
   44    22        QM_ASSIGN                                        ~16     null
         23        ADD_ARRAY_ELEMENT                                ~11     ~16, 'LINE_DATA'
   48    24        FETCH_DIM_IS                                     ~17     !4, 4
         25        COALESCE                                         ~18     ~17
   44    26        QM_ASSIGN                                        ~18     null
         27        ADD_ARRAY_ELEMENT                                ~11     ~18, 'INITIALS'
         28        SEND_VAL                                                 ~11
         29        DO_ICALL                                                 
   50    30        ECHO                                                     '%0A'
   41    31    > > JMP                                                      ->3
         32    >   FE_FREE                                                  $7
   52    33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.07 ms | 1400 KiB | 17 Q