With the following `test.file`: ```text [&_*]:foobar "[&_*]:foobar" ``` With actual `sed` on macOS: ```shell $ sed 's/\[\([^\&]*\)\&/\[\1\&/g' test.file [&_*]:foobar "[&_*]:foobar" ``` With `shx sed`: ```shell npx shx sed 's/\[\([^\&]*\)\&/\[\1\&/g' test.txt [&_*]:foobar "[&_*]:foobar" ``` Node version: v20.12.2