There are many questions asking about how to use a variable within a sed pattern, for example: sed "s/re/$VAR/" file, but I want to perform a substitution on a variable. So far, I have been using echo to do this:
echo "$VAR" | sed 's/re/new/'
But, though this works, it seems messy. Is there a simpler/more elegant way of doing this in bash or zsh?