3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <figure data-trix-attachment="{&quot;content&quot;:&quot;<span class=\&quot;trix-token\&quot; data-token-id=\&quot;landlord_name\&quot;>Jméno pronajímatele</span>&quot;}" data-trix-content-type="undefined" class="attachment attachment--content"><span class="trix-token">Jméno pronajímatele</span><figcaption class="attachment__caption"></figcaption></figure> HTML; $tokenId = 'landlord_name'; // Správný regulární výraz $figurePattern = '/(<figure[^>]*data-trix-attachment="[^"]*data-token-id=\\&quot;' . $tokenId . '\\&quot;.*?"[^>]*>)(.*?)<\/figure>/s'; // Náhrada obsahu $replacement = '$1<span class="trix-token ' . $tokenId . ' tokenClass" data-token-id="' . $tokenId . '">test</span></figure>'; // Proveď nahrazení $html = preg_replace($figurePattern, $replacement, $html); echo $html;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n4lch
function name:  (null)
number of ops:  18
compiled vars:  !0 = $html, !1 = $tokenId, !2 = $figurePattern, !3 = $replacement
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cfigure+data-trix-attachment%3D%22%7B%26quot%3Bcontent%26quot%3B%3A%26quot%3B%3Cspan+class%3D%5C%26quot%3Btrix-token%5C%26quot%3B+data-token-id%3D%5C%26quot%3Blandlord_name%5C%26quot%3B%3EJm%C3%A9no+pronaj%C3%ADmatele%3C%2Fspan%3E%26quot%3B%7D%22+data-trix-content-type%3D%22undefined%22+class%3D%22attachment+attachment--content%22%3E%3Cspan+class%3D%22trix-token%22%3EJm%C3%A9no+pronaj%C3%ADmatele%3C%2Fspan%3E%3Cfigcaption+class%3D%22attachment__caption%22%3E%3C%2Ffigcaption%3E%3C%2Ffigure%3E'
    6     1        ASSIGN                                                   !1, 'landlord_name'
    9     2        CONCAT                                           ~6      '%2F%28%3Cfigure%5B%5E%3E%5D%2Adata-trix-attachment%3D%22%5B%5E%22%5D%2Adata-token-id%3D%5C%26quot%3B', !1
          3        CONCAT                                           ~7      ~6, '%5C%26quot%3B.%2A%3F%22%5B%5E%3E%5D%2A%3E%29%28.%2A%3F%29%3C%5C%2Ffigure%3E%2Fs'
          4        ASSIGN                                                   !2, ~7
   12     5        CONCAT                                           ~9      '%241%3Cspan+class%3D%22trix-token+', !1
          6        CONCAT                                           ~10     ~9, '+tokenClass%22+data-token-id%3D%22'
          7        CONCAT                                           ~11     ~10, !1
          8        CONCAT                                           ~12     ~11, '%22%3Etest%3C%2Fspan%3E%3C%2Ffigure%3E'
          9        ASSIGN                                                   !3, ~12
   15    10        INIT_FCALL                                               'preg_replace'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !3
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !0, $14
   17    16        ECHO                                                     !0
   18    17      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.64 ms | 997 KiB | 14 Q