$start_time = '1030'; $pattern = '/(?<=dd)30/'; $start_time = preg_replace($pattern, '50', $start_time); //result: 1050