There is a response from the equipment https://pastebin.com/VavtUJpz

I started like this $x= explode("------\r\n", str_replace('', '', $output));

You need to allocate IP address: 100.69.0.255 . There are many of them there and Interface: GigabitEthernet0 / 21

Put everything in an array, so it was more convenient to run.

    1 answer 1

    This option is suitable?

     $result = array(); $pattern = '%Device\sID.+?(\IP\saddress:\s[\d\.]+).+?(\Interface:\s[\w]+\/\w+).+?Version%s'; $string = 'REN-24-AFGSD-3-t510................'; preg_match_all($pattern, $string, $matches, PREG_SET_ORDER, 0); foreach($matches as $item) { $result[] = array( $item[1], $item[2] ); } var_dump($result); 

    You can improve, or fix the regular schedule as you need.