Using sed to replace space delimited strings
<p><code>echo 'bar=start "bar=second CONFIG="$CONFIG bar=s buz=zar bar=g bar=ggg bar=f bar=foo bar=zoo really?=yes bar=z bar=yes bar=y bar=one bar=o que=idn"' | sed -e 's/^\|\([ "]\)bar=[^ ]*[ ]*/\1/g'</code>  </p>

<p>Actual output:  </p>

<p><code>CONFIG="$CONFIG buz=zar bar=ggg bar=foo really?=yes bar=yes bar=one que=idn"</code></p>

<p>Expected output:  </p>

<p><code>CONFIG="$CONFIG buz=zar really?=yes que=idn"</code></p>

<p>What I'm missing in my regex?   </p>

<p><strong>Edit:</strong>  </p>

<p>This works as expected (with GNU <code>sed</code>):  </p>

<p><code>'s/\(^\|\(['\''" ]\)\)bar=[^ ]*/\2/g; s/[ ][ ]\+/ /g; s/[ ]*\(['\''"]\+\)[ ]*/\1/g'</code></p>