I'm running a script to pull information from a 'show' command on a Cisco that I want to put in to a MYSQL database and have this automated, so I just look at the 'final data' output. As an FYI I cannot use 'SNMPget' as the devices don't have OID's for this output :

So the flow of the information from the show command is like such:

```
ABC DEF GHI JKL
      TY123 AB456 RT789

```

So I want to initially format it to look like:

```
ABC DEF GHI JKL 123 456 789

```

So I am removing the linebreaks and removing specific text before the numbers.

Then I want to be able to, replace the whitespace with commas, then line break after the first sequence is complete so in this example after the amount of commas is done for a sequence it starts a new line. 

So it looks like:

```
ABC,DEF,GHI,JKL,123,456,789,
MNO,PQR,STU,VWX,987,654,321,

```

I've tried to play around using a `str_replace()` and `split` command sets but I can't seem to get it to do what I want to do.

Could someone help with an example that would achieve the above please?