3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html_string = " <div> Below are object Node with the html code </div> <script> alert('i want this to be replaced. it has no newline'); </script> <div> I don't want this to be replaced </div> <script> console.log('i also want this to be replaced. It has newline'); </script> <div> This is a div tag and not a script, so it should not be replaced </div> <script> console.warn(Finally, this should be replaced, it also has newline'); </script> <div> The above is the final result of the replacements </div> "; $regex = '/(?:\<script\>)(.*?)(?:\<\/script\>)/ims'; $result = preg_replace($regex, '<!-- THIS SCRIPT CONTENT HERE HAS BEEN ALTERED -->', $html_string); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TaR76
function name:  (null)
number of ops:  7
compiled vars:  !0 = $html_string, !1 = $regex, !2 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%0A%0A%0A%3Cdiv%3E+Below+are+object+Node+with+the+html+code+%3C%2Fdiv%3E%0A%0A%3Cscript%3E+alert%28%27i+want+this+to+be+replaced.+it+has+no+newline%27%29%3B+%3C%2Fscript%3E%0A%0A%3Cdiv%3E+I+don%27t+want+this+to+be+replaced+%3C%2Fdiv%3E%0A%0A%3Cscript%3E+%0A++++console.log%28%27i+also+want+this+to+be+replaced.+It+has+newline%27%29%3B+%0A%3C%2Fscript%3E%0A%0A%3Cdiv%3E+This+is+a+div+tag+and+not+a+script%2C+so+it+should+not+be+replaced+%3C%2Fdiv%3E%0A%0A%3Cscript%3E+console.warn%28Finally%2C+this+should+be+replaced%2C+it+also+has+newline%27%29%3B+%0A%3C%2Fscript%3E%0A%0A%3Cdiv%3E+The+above+is+the+final+result+of+the+replacements+%3C%2Fdiv%3E+'
   23     1        ASSIGN                                                       !1, '%2F%28%3F%3A%5C%3Cscript%5C%3E%29%28.%2A%3F%29%28%3F%3A%5C%3C%5C%2Fscript%5C%3E%29%2Fims'
   24     2        FRAMELESS_ICALL_3                preg_replace        ~5      !1, '%3C%21--+THIS+SCRIPT+CONTENT+HERE+HAS+BEEN+ALTERED+--%3E'
          3        OP_DATA                                                      !0
          4        ASSIGN                                                       !2, ~5
   25     5        ECHO                                                         !2
   26     6      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.04 ms | 2327 KiB | 13 Q