3v4l.org

run code in 500+ PHP versions simultaneously
<?php $strings = [ "I-IVWM_Ask-21_(max_2h)", "D-7849_DG303_(max_4h)", "Aliante_Privato" ]; foreach ($strings as $str) { $pattern = "/^[^\s()]+(?:\([^()]*\))?$/"; echo preg_replace_callback($pattern, function ($x) { return trim(preg_replace("/[()_]+/", " ", $x[0])); }, $str) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 13
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/gn3vh
function name:  (null)
number of ops:  15
compiled vars:  !0 = $strings, !1 = $str, !2 = $pattern
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    9     1      > FE_RESET_R                                           $4      !0, ->13
          2    > > FE_FETCH_R                                                   $4, !1, ->13
   10     3    >   ASSIGN                                                       !2, '%2F%5E%5B%5E%5Cs%28%29%5D%2B%28%3F%3A%5C%28%5B%5E%28%29%5D%2A%5C%29%29%3F%24%2F'
   11     4        INIT_FCALL                                                   'preg_replace_callback'
          5        SEND_VAR                                                     !2
          6        DECLARE_LAMBDA_FUNCTION                              ~6      [0]
   13     7        SEND_VAL                                                     ~6
          8        SEND_VAR                                                     !1
   11     9        DO_ICALL                                             $7      
   13    10        CONCAT                                               ~8      $7, '%0A'
         11        ECHO                                                         ~8
    9    12      > JMP                                                          ->2
         13    >   FE_FREE                                                      $4
   14    14      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gn3vh
function name:  {closure:/in/gn3vh:11}
number of ops:  7
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   12     1        FETCH_DIM_R                                          ~1      !0, 0
          2        FRAMELESS_ICALL_3                preg_replace        ~2      '%2F%5B%28%29_%5D%2B%2F', '+'
          3        OP_DATA                                                      ~1
          4        FRAMELESS_ICALL_1                trim                ~3      ~2
          5      > RETURN                                                       ~3
   13     6*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
154.46 ms | 1434 KiB | 9 Q