I have this string:
str='1 2 3 var="foo bar" 4 5 6'
Also it could be like this:
str="1 2 3 var='foo bar' 4 5 6"
How would I replace spaces with +
only inside quotes(double or single)?
The result should be like:
1 2 3 var="foo+bar" 4 5 6
or
1 2 3 var='foo+bar' 4 5 6
In case the var is single quoted.
var
can be anything, it is not strong match.
Also it could be missing at all, like this:
str='1 2 3 "foo bar" 4 5 6'
I don't want to use awk, sed, or perl to do this.