Question: I have the data given below with other lines of data in a huge file to be more specific this is a .json file, I have stripped the whole file except for this one catch.

**Data:**

* ,"value":["ABC-DE","XYZ-MN"]
* ,"value":["MNO-RS"],"sub\_id":01
* "value":"[\"NEW-XYZ\"]","
* ,"value":["ABC-DE","XYZ-MN","MNO-BE","FRS-ND"]

I want the data to look like this

* ,"value":["ABC-DE,XYZ-MN"]-Changed
* ,"value":["MNO-RS"],"sub\_id":01-Unchanged
* "value":"[\"NEW-XYZ\"]","-Unchnaged
* ,"value":["ABC-DE,XYZ-MN,MNO-BE,FRS-ND"]-Changed

So far I have this piece of code however it seems to be replacing the whole files "," with , and not the ones just within []

```
sed 's/\(\[\|\","\|\]\)/\,/g' testfile_1.txt >testfile_2.txt

```

Any help would be great

\*\*Note: Edited fourth condition

Cheers.

Answer: 
That's tougher without the non-greedy matching perl regex offers, but this seems to do it.

```
sed -e 's/\([^\[]*\"[A-Z\-]*\)\",\"\(.*\)/\1,\2/'

```
Thank you for your contributions @clearlight

Here is my solution to the problem with multiple occurrences;

```
sed -e ': a' -e 's/\(\[[^]]*\)","/\1,/' -e 't a' testfile_1.txt >testfile_2.txt

```

Using label 'a' till end of label 'a'

pseudocode:

```
while (not end of line){ replace "," with ' }

```