3v4l.org

run code in 300+ 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}
number of ops:  12
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'trim'
          2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%5B%28%29_%5D%2B%2F'
          4        SEND_VAL                                                 '+'
          5        FETCH_DIM_R                                      ~1      !0, 0
          6        SEND_VAL                                                 ~1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10      > RETURN                                                   $3
   13    11*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.23 ms | 1001 KiB | 16 Q