Reply To: GREP to replace space with nonbreaking space

Home Page / Forums / General InDesign Topics (CLOSED) / GREP to replace space with nonbreaking space / Reply To: GREP to replace space with nonbreaking space

#66378

You get your original spaces back because ‘$0’ inserts the exact entire found text again. You can use parentheses to indicate a part of the search string, and then use ‘$1’ to insert the first group in the Replace field, ‘$2’ for the second, etc. — up to 9 groups. But of course you can only ‘recall’ a numbered group in Replace if you defined it with parentheses in the Search field (and I bet that’s why your own attempts with ‘$2’ failed).

A second change is you do not have to list all of your search strings separately; after all there has to be only ONE character, out of a certain limited set, between your spaces.

All together, you can search for this

([+=~=×÷])

and replace with

~S$1~S

There was a single ‘?’ in your search query, and checking the rest I suppose it’s a copy-paste problem and it should have been the ‘multiply’ operator × instead. I would also rather use a *real* mathematical minus ‘-‘ (U+2212) rather than an en-dash, because it aligns with the ‘+’ and is a bit thicker (then again, not all fonts contain it).

This article was last modified on December 8, 2013

Comments (0)

Loading comments...