3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = "// blah blah blah\n\nconst filename = \"\";\n\n// blah blah blah"; echo preg_replace('~^(\h*const\s+filename\s*=\s*).+~mi', '$1"NEW VALUE";', $string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DCO5F
function name:  (null)
number of ops:  5
compiled vars:  !0 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%2F%2F+blah+blah+blah%0A%0Aconst+filename+%3D+%22%22%3B%0A%0A%2F%2F+blah+blah+blah'
    4     1        FRAMELESS_ICALL_3                preg_replace        ~2      '%7E%5E%28%5Ch%2Aconst%5Cs%2Bfilename%5Cs%2A%3D%5Cs%2A%29.%2B%7Emi', '%241%22NEW+VALUE%22%3B'
          2        OP_DATA                                                      !0
          3        ECHO                                                         ~2
          4      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
141.38 ms | 1858 KiB | 13 Q