3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sampleString = "<a href='{{url}}'>Link</a> <p>This text {{url}} will not get replaced</p> <a href='{{url}}' download='true'>Another Link</a>"; $regex = "/(?<=href=')()(?={{url}}.*>)/"; $replaced = preg_replace($regex, "https://myurl.com?redirect=\1", $sampleString); echo $replaced;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LhBUs
function name:  (null)
number of ops:  10
compiled vars:  !0 = $sampleString, !1 = $regex, !2 = $replaced
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Ca+href%3D%27%7B%7Burl%7D%7D%27%3ELink%3C%2Fa%3E%0A%0A%3Cp%3EThis+text+%7B%7Burl%7D%7D+will+not+get+replaced%3C%2Fp%3E%0A%0A%3Ca+href%3D%27%7B%7Burl%7D%7D%27+download%3D%27true%27%3EAnother+Link%3C%2Fa%3E'
    9     1        ASSIGN                                                   !1, '%2F%28%3F%3C%3Dhref%3D%27%29%28%29%28%3F%3D%7B%7Burl%7D%7D.%2A%3E%29%2F'
   11     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 'https%3A%2F%2Fmyurl.com%3Fredirect%3D%01'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   13     8        ECHO                                                     !2
   14     9      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.93 ms | 1009 KiB | 14 Q