3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('CALCULATION_REGEXP_STRUCTURED_REFERENCE', '([\p{L}_\\\\][\p{L}\p{N}\._]+)?(\[(?>[^\[\]]|(?R))+\])'); $formula = '=SUM(Sales_Data[[#This Row],[Q1]:[Q4]])'; $offset = 5; // This works // No start anchor, but using the preg_match() $offset argument to specify the start point for the search preg_match('/' . CALCULATION_REGEXP_STRUCTURED_REFERENCE . '/misu', $formula, $matches, 0, $offset); var_dump($matches); // This doesn't work // Creating a substring for the part of the formula that we want to search $partialFormula = substr($formula, $offset); var_dump($partialFormula); // and using the start anchor in our regexp preg_match('/^' . CALCULATION_REGEXP_STRUCTURED_REFERENCE . '/misu', $partialFormula, $matches); var_dump($matches);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cttXo
function name:  (null)
number of ops:  39
compiled vars:  !0 = $formula, !1 = $offset, !2 = $matches, !3 = $partialFormula
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'CALCULATION_REGEXP_STRUCTURED_REFERENCE'
          2        SEND_VAL                                                 '%28%5B%5Cp%7BL%7D_%5C%5C%5D%5B%5Cp%7BL%7D%5Cp%7BN%7D%5C._%5D%2B%29%3F%28%5C%5B%28%3F%3E%5B%5E%5C%5B%5C%5D%5D%7C%28%3FR%29%29%2B%5C%5D%29'
          3        DO_ICALL                                                 
    5     4        ASSIGN                                                   !0, '%3DSUM%28Sales_Data%5B%5B%23This+Row%5D%2C%5BQ1%5D%3A%5BQ4%5D%5D%29'
    6     5        ASSIGN                                                   !1, 5
   10     6        INIT_FCALL                                               'preg_match'
          7        FETCH_CONSTANT                                   ~7      'CALCULATION_REGEXP_STRUCTURED_REFERENCE'
          8        CONCAT                                           ~8      '%2F', ~7
          9        CONCAT                                           ~9      ~8, '%2Fmisu'
         10        SEND_VAL                                                 ~9
         11        SEND_VAR                                                 !0
         12        SEND_REF                                                 !2
         13        SEND_VAL                                                 0
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
   11    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   16    19        INIT_FCALL                                               'substr'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $12     
         23        ASSIGN                                                   !3, $12
   17    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                                 
   19    27        INIT_FCALL                                               'preg_match'
         28        FETCH_CONSTANT                                   ~15     'CALCULATION_REGEXP_STRUCTURED_REFERENCE'
         29        CONCAT                                           ~16     '%2F%5E', ~15
         30        CONCAT                                           ~17     ~16, '%2Fmisu'
         31        SEND_VAL                                                 ~17
         32        SEND_VAR                                                 !3
         33        SEND_REF                                                 !2
         34        DO_ICALL                                                 
   20    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !2
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.55 ms | 1396 KiB | 21 Q