You need to add a backreference to the matched term, typically just using an escaped numeral like \1 or $1.
If you just to replace ANY dash surrounded by spaces (one or many), you need to find:
and replace it to:
What does it do?
it searchs for any number of any spaces, then any dash, then any number of any spaces
and replaces it for non-breaking space, then em-dash, then normal space
Moving to InDesign forum
If you just need to replace the hyphen with an em dash, and you're familiar with the content (sure that there are only single spacebar spaces before and after the hyphen), you can simplify it to:
If you need to account for more than one space, different kinds of spaces, etc., then a more robust expression (like those above) may be needed.
Replace by: ~_
Someday I'll get used to using the \K expression. Have you found that in InDesign there is an advantage to using it over creating groups? Less work? Speedier searches?
Erica or Obi Wan,
For us mortals who do not know GREP, what is the function of \K ?
It basically ignores everything in the string before it, meaning find it in the pattern, but keep it as it is. So it'll find the digit and the horizontal space, but ignore it when it comes to the formatting...thus only formatting the hyphen to an em dash.