3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/(?:"\K([^_\r\n]+)|\G(?!^))(?=[^":\r\n]*")(?=[^:\r\n]*:)_?([a-zA-Z])([^"_\r\n]*)/'; $str = '"aa_bb" : "foo" "pp_Qq" : "bar" "Xx_yY_zz" : "foobar" "Xx_yYyyyyyYyY_zz_a" : "foobar"'; $result = preg_replace_callback($re, function($matches) { return strtolower($matches[1]) . strtoupper($matches[2]) . strtolower($matches[3]); }, $str); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Nb7D
function name:  (null)
number of ops:  11
compiled vars:  !0 = $re, !1 = $str, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%28%3F%3A%22%5CK%28%5B%5E_%5Cr%5Cn%5D%2B%29%7C%5CG%28%3F%21%5E%29%29%28%3F%3D%5B%5E%22%3A%5Cr%5Cn%5D%2A%22%29%28%3F%3D%5B%5E%3A%5Cr%5Cn%5D%2A%3A%29_%3F%28%5Ba-zA-Z%5D%29%28%5B%5E%22_%5Cr%5Cn%5D%2A%29%2F'
    4     1        ASSIGN                                                   !1, '%22aa_bb%22+%3A+%22foo%22%0A%0A%22pp_Qq%22+%3A+%22bar%22%0A%0A%22Xx_yY_zz%22+%3A+%22foobar%22%0A%22Xx_yYyyyyyYyY_zz_a%22+%3A+%22foobar%22'
   11     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   13     5        SEND_VAL                                                 ~5
          6        SEND_VAR                                                 !1
   11     7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
   15     9        ECHO                                                     !2
   16    10      > 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/7Nb7D
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'strtolower'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        INIT_FCALL                                               'strtoupper'
          6        FETCH_DIM_R                                      ~3      !0, 2
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                         $4      
          9        CONCAT                                           ~5      $2, $4
         10        INIT_FCALL                                               'strtolower'
         11        FETCH_DIM_R                                      ~6      !0, 3
         12        SEND_VAL                                                 ~6
         13        DO_ICALL                                         $7      
         14        CONCAT                                           ~8      ~5, $7
         15      > RETURN                                                   ~8
   13    16*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.72 ms | 1013 KiB | 16 Q