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